Example of jQuery regular expression-based form verification function, jquery Regular Expression
This document describes jQuery's form verification function based on regular expressions. We will share this with you for your reference. The details are as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Appendix: Common js verification functions:
Website homepage form js:
Function checkVaild () {var User = $ ("# Mobile"). val (); var reg =/^ (\ + \ d {2, 3 }\-)? \ D {11 }$/; if (User = "") {alert ("mobile phone number cannot be blank"); return false;} if (! Reg. test (User) {alert ("Incorrect mobile phone number"); return false;} return true ;}
Filter special characters in a regular expression:
Function doValidate (value) {vkeyWords =/^ [^ '~! @ # $ % ^ & * () + = |\\] [\] \{\}:;' \,. <>/?] {1} [^ '~! @ $ % ^ & () + =|\\] [\] \{\}:; '\,. <>?] {0, 19} $/; if (value = null | value = "") {alert ("enter the correct query parameter"); return false;} if (! VkeyWords. test (value) {alert ("the query parameter you entered is incorrect. Please enter it again! "); Return false;} return true ;}
PS: here we will provide two very convenient Regular Expression tools for your reference:
JavaScript Regular Expression online testing tool:
Http://tools.jb51.net/regex/javascript
Regular Expression generation tool:
Http://tools.jb51.net/regex/create_reg