Yes, you’d need to add a custom rule for that.
http://docs.jquery.com/Plugins/Validation/#List_of_built-in_Validation_methods
If you want to require a specific number of characters, you’d want to use minlength and maxlength.
jQuery(document).ready(function($) {
$(“#vfb-zip-code-95”).validate({
rules: {
field: {
required: true,
minlength: 5,
maxlength: 5
}
}
});
Here is the snippet I wrote out for the “Zip Code field on this page: http://www.styletrader.biz/signup/
It still wont validate a min or max length of characters. I need your help haha.
You are close.
$("#newsletter-sign-up").validate({
rules: {
'vfb-zip-code-95': {
required: true,
minlength: 5,
maxlength: 5
}
}
});
jQuery(document).ready(function($) {
$.datepicker.setDefaults({
dateFormat: 'mm-dd-yy',
numberOfMonths: 1,
changeMonth: true,
changeYear: true,
yearRange: "c-90:c+1"
});
});
This is a piece of code I already had in place in the “my-js.js file.
I feel really dumb asking this, but how do I add this:
$("#newsletter-sign-up").validate({
rules: {
'vfb-zip-code-95': {
required: true,
minlength: 5,
maxlength: 5
}
}
});
to what I currently have?
jQuery(document).ready(function($) {
$.datepicker.setDefaults({
dateFormat: 'mm-dd-yy',
numberOfMonths: 1,
changeMonth: true,
changeYear: true,
yearRange: "c-90:c+1"
});
$("#newsletter-sign-up").validate({
rules: {
'vfb-zip-code-95': {
required: true,
minlength: 5,
maxlength: 5
}
}
});
});
Thanks Matt! That did the trick.