Quantcast
Channel: validator Discussions Rss Feed
Viewing all articles
Browse latest Browse all 20

New Post: How to apply validation on Two Buttons

$
0
0
Well you can have different validation groups on a page, e.g:
<input type="text" validate="group1" require="Please enter value" />
<input type="text" validate="group2" require="Please enter value" />

<input type="submit" value="Accept" onclick="return validate('group1');">
<input type="submit" value="Reject" onclick="return validate('group2');">
But if you want a textbox shared between 2 validation groups then you'll need to change the following jquery.validator.js code (change css selector to contains instead of equals):
$("*[validate=" + group + "]").each(function(i, elm) {
change to:
$("*[validate*=" + group + "]").each(function(i, elm) {
Then you can add multiple validation groups to a single textbox:
<input type="text" validate="group1 group2" require="Please enter value" />
<input type="text" validate="group2" require="Please enter value" />

<input type="submit" value="Accept" onclick="return validate('group1');">
<input type="submit" value="Reject" onclick="return validate('group2');">
With this change though 'group1' will also validate 'group12' fields since group12 text contains group1 so you'll just need to be aware.

Viewing all articles
Browse latest Browse all 20

Trending Articles