html - jquery custom validation rule -
in form used custom validation rule date format
$.validator.addmethod( "usdate", function(value, element) { // date mm/dd/yyyy return value.match(/^\d\d?\/\d\d?\/\d\d\d\d$/); } );
in validator called
phone : { usdate: true },
this working fine. need modify this rule called if phone field has filled something. if filed blank no need validate field.
and value.match(/^\d\d?\/\d\d?\/\d\d\d\d$/)
working 25/80/1212 ...
but month 1 12 , date 1 31 ...
how change code. please me. thanks
$.validator.addmethod( "usdate", function(value, element) { // date mm/dd/yyyy return value.match(/^(0[0-9]|1[0-2])[\/](0[0-1]|1[0-9]|2[0-9]|3[0-1])[\/]\d{4}$/); } );
in validator called as
phone : { required: true, usdate: true },
Comments
Post a Comment