Jquery validation plugin question -
i need validate account number, can either 6 number (111111), or 2 letter 6 numbers (xx111111).
can please show me how it? thank you.
as @teja says, need use .addmethod
regular expression. believe should work:
$.validator.addmethod("accountnumber", function(value, element) { return this.optional(element) || /^(\w{2})?\d{6}$/.test(value); }, "please enter valid account number"); $("#form").validate({ rules: { account: { accountnumber: true } } });
Comments
Post a Comment