Regular-expression validation
// Email var emailreg =/^ ([a-za-z0-9_\.\-]) +\@ (([a-za-z0-9\-]) +\.) + ([a-za-z0-9]{2,4}) +$/; = document.getElementById ("email"). value; if (! emailreg.test (email)) { Win_alert (' The mailbox you entered is not in the correct format! ' ); return ; }
//Mobile phone number varPhonereg =/^ ( -[0-9]{9})| ( the[0-9][0-9]{8})| ( -[0-9][0-9]{8})$/; if(!phonereg.test (phone)) {Win_alert ('phone input format is not correct!'); return; }
// Identification Number Verification Idcard = document.getElementById ("idcard"). value; var idcardreg =/(^\d{}$) | (^\d{}$) | (^\d{} (\d| X|X) $)/; if (! idcardreg.test (Idcard)) { Win_alert (' ID card input is not legal! '); return ; }
For enquiries, please add QQ:;QQ Group:
Web Development Common JS authentication, using regular expressions to verify the mailbox, cell phone, ID and other input