//Verify Chinese namefunctionIschinaname (name) {varPattern =/^[\u4e00-\u9fa5]{1,6}$/; returnpattern.test (name);} //Verify your phone numberfunctionIsphoneno (phone) {varPattern =/^1[34578]\d{9}$/; returnpattern.test (phone);} //Verify IDfunctionIscardno (card) {varPattern =/(^\d{15}$) | (^\d{18}$) | (^\d{17} (\d| X|X) $)/; returnpattern.test (card);} //validation Functionsfunctionformvalidate () {varstr = "; //Judge name if($.trim (' #name '). Val ()). length = = 0) {str+ = ' name not entered \ n '; $(' #name '). focus (); } Else { if(Ischinaname ($.trim ($ (' #name '). Val ())) = =false) {str+ = ' name not legal \ n '; $(' #name '). focus (); } } //determine the phone number if($.trim (' #phone '). Val ()). length = = 0) {str+ = ' Mobile number not entered \ n '; $(' #phone '). focus (); } Else { if(Isphoneno ($.trim ($ (' #phone '). val ()) = =false) ) {str+ = ' mobile phone number not correct \ n '; $(' #phone '). focus (); } } //Verify ID if($.trim (' #identity '). Val ()). length = = 0) {str+ = ' ID number not entered \ n '; $(' #identity '). focus (); } Else { if(Iscardno ($.trim ($ (' #identity '). Val ())) = =false) {str+ = ' ID number is incorrect; \ n '; $(' #identity '). focus (); } } //Verify Address if($.trim (' #address '). Val ()). length = = 0) {str+ = ' address not entered \ n '; $(' #address '). focus (); } //Submit if there are no errors if(str! = ") {alert (str); return false; } Else { $('. Auth-form '). Submit (); }} $(' #submit '). On (' click ',function() {formvalidate ();});
Jquery Regular validation