jQuery validation plugin is a helpful and easy to use validation tool to validate form.
From the examples shown in the jQuery validation plugin official site, we can see the validation on single form field only.
Credit card validation and Email validation with jQuery in my blog are the single form field validation example.
We can actually validate multiple form fields in one shot with jQuery.
Below is the sample syntax to validate multiple form fields with jQuery validation plugin.
COMMA(,) is the separator of multiple form fields.
so now let's combine both the Credit card validation and Email validation sample codes into 1.
Done!!
From the examples shown in the jQuery validation plugin official site, we can see the validation on single form field only.
Credit card validation and Email validation with jQuery in my blog are the single form field validation example.
We can actually validate multiple form fields in one shot with jQuery.
Below is the sample syntax to validate multiple form fields with jQuery validation plugin.
COMMA(,) is the separator of multiple form fields.
<script>
$(document).ready(function(){
$("#myform").validate({
rules: {
field1: {
email: true
},
field2: {
required: true
},
fieldN: {
creditcard: true
}
}
});
});
</script>
so now let's combine both the Credit card validation and Email validation sample codes into 1.
<script>
$(document).ready(function(){
$("#myform").validate({
rules: {
ccard: {
required: true,
creditcard: true
},
emailAddr: {
required: true,
email: true
}
}
});
});
</script>
related jQuery validation articles:
- Email
- Credit card
- Error message customization
- Using jQuery validation plugin in JSF
- Multilingual error messages
- jQuery Validation Plugin localization
- Error handling in jQuery Validation Plugin
- Credit card
- Error message customization
- Using jQuery validation plugin in JSF
- Multilingual error messages
- jQuery Validation Plugin localization
- Error handling in jQuery Validation Plugin
Done!!
No comments:
Post a Comment