Thursday, August 9, 2012

Zip code accept only 5 or 9 digits

HTML


Jquerty


$.validator.addMethod('zipcode', function(postalcode,element){ return this.optional(element) || postalcode.match(/^\d{5}$|^\d{5}\-\d{4}$/) || postalcode.match(/^\d{9}$|^\d{9}\-\d{8}$/); },"Please enter 5 or 9 digits valid zip code");

jQuery(document).ready(function () { $("#mainForm").validate({ rules: { txtBillingInfoPostalCode:{zipcode:true} } }); });


No comments:

Post a Comment