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         }     }  }); 

example: http://jsfiddle.net/andrewwhitaker/tuab7/


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -