Let me share with you the instance code of HTML with html "> regular expression test form. The specific code content is shown below:
<span style = font-size: 24px; color:#cc6600;> regular expression is a very useful method for testing the laws and regulations in the JavaScript script. But it is different from the regular expression in Java. It needs to start with^on the RegEx rules and ends at $. </span>
<span style = font-size: 24px; color:#cc6600;> Let's take a look at an instance. </span>
<span style = font-size: 18px;> <! Doctype html> <html lang = EN> <high> <meta charset = UTF-8> <Title> Title </title> <Style> FORM TABLE TR TD {border : 1px Solid Lightgrey; Text-Align: Center;} FORM TABLE TR TD Input {Width: 97%;} </style> <Script Language = Javascript Type = Text/Javascript> // Judgment rules (regular expression) Function GOTO () () {var name = document.GetelementByid (name); var pwd = document.GetelementByid (pwd); VAR PWD2 = DOCUMENT.GetelementByid (PWD2); VAR PNUM = DOCUMEN T.GetelementByid (PNUM); VAR Phone = Document.GetelementByid ( Phone); VAR Telephone = Document.GetelementByid (Telephone); var email = document.GetelementByid (email); if (name.value.trim (). (The length of the username must be greater than eight); name.focus () name.value =; Return;} // The rules must include a lowercase letter, digital var regex =/^(?! (?:/d+| [a-za-z]+|/da- z]+| [/da-z]) $) [/da-za-z] {6,} $/; // var regex =/^[a-z0-9] {10,20} $/; if (! pwd.value.match (regex)) {alert (the password does not meet the regulations); pwd.focus () pwd.value =; Return;} if (pwd.value! = pwd2.value) {Alert (two times The input password is different); pwd2.focus () pwd.value =; pwd2.value =; Return;} var rege =/^/d {17} x $ |/d {15} $/; if (!! rege.test (pnum.value) {alert (the ID card does not meet the regulations); pnum.focus () pnum.value =; Return;} var regex2 =/{4}-/d {7} $/ ; // Judge the seat machine number if (! Regex2.test (phone.value)) {alert (the landline number does not meet the regulations); phone.focus () phone.value =; return;} var regex3 =/^1 [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5,7,8]/d {9} $/; if (! Regex3.test (telephone.value)) {alert (the mobile phone number does not meet the regulations); Telephone.focus () Telephone.Value =; Return;}/ The/test method must be righteous with back slope Var regex4 =/^/w+ (#-+./w+) *@/w+ ([-. ,/w+) */w+ (#-., /w+ )*$/; if (! regex4.test (email.value)) {alert (email.focus () email.value =; Return;} </head> <body > <FORM> <Table style = Width: 600px; Height: 300px; Border: 1px Solid Lightgrey> <TD WIDTH = 18%> Login Name: </TD> <input ID = NameType = Text> </td> <td width = 50%> greater than eight bits </td> </tr> <TD> Login password: </td> <input id = pwdtype = password> </td > <TD> The length is greater than ten digits, including the number of letters </td> </textarea> </td> </tr> <tr> = password> </td> </tr> <l> <TD> ID number: </td> <input ID = pnum type = text> </td> <TD> 15 -bit or 18 -bit last One is X </TD> </TR> <TR> <TD> Fixed Telephone: </td> <td> <input ID = Phonetype = Text> </td> <TD> Format xxxx-xxxxxxx </td> </tr> <l> <TD> Mobile Number: </td> <td> <input ID = Telephonetype = Text> </TD> <TD> 11 -bit integer </td> </tr> <tr> TD> Email: </td> <td> <input id = emailtype = Text> </td> <td> [email protected] [email protected] </td> </tr> <TD> The place of living now: </td> <TD> <select> <option>-Select the province- </option> Beijing </option> <option> Hebei </option> Guangxi Guangxi </option> </select> </td> <TD> <select> <option>-Select the city- </option> <option> Yantai </option> <Option> Qingdao </option> <option> Harbin </option> </select> </td> </tr> <l> <td colorpan = 1> </td> <input id = submit type = button value = Submit registration information style = width: 100px Onclight = Goto ()> </TD> <TD> <input Type = Resyet Value = Resetting style = Width: 60px> </TD> </Table> </Form> </body> < /html> </span> Attachment: Some commonly used rules:^// d+ $ // Non -negative integer (positive integer+ 0)
^[0-9]*[1-9] [0-9]*$ // Positive integer
^((-// d+) | (0+)) $ // Non-positive integer (negative integer+0)
^-[0-9]*[1-9] [0-9]*$ // negative integer
^-? // d+$ // integer
^// d+(//.// d+)? $ // Non -negative floating point number (Positive floating point number+0)
^([0-9]+//. [0-9]*[1-9] [0-9]*) | ([0-9]*[1-9] [0-9]*/ /._9 /)|| wenshu (0-9 shine
^((-// d+(//// d+)?) | (0+(//. 0+)?)) $ // Non-positive floating point number (negative floating point number+0)
^(-([0-9]+//. [0-9]*[1-9] [0-9]*) | ([0-9]*[1-9] [0-9] *//. [0-9]+) | ([0-9]*[1-9] [0-9])) $ // The number of negative floating points
^(-? // d+) (//.// d+)? $ // The number of floating points
^[A-Za-Z]+$ // String consisting of 26 English letters
^[Az]+$ // String consisting of uppercase 26 English letters
^[AZ]+$ // String consisting of a lowercase of 26 English letters
^[A-ZA-Z0-9]+$ // String consisting of numbers and 26 English letters
^// W+$ // String consisting of numbers, 26 English letters, or underlined lines
^[// w-]+(//. [// w-]+)*@[// w-]+(//. [// w-]+)+$ // email address
^[a-za-z]+: // (// w+(-// w+)*) (//. (// w+(-// w+)*))*(//? // s* )? $ // url
The above is the instance code of the HTML introduced by the editor to you. I hope it will be helpful to everyone. If you have any questions, please leave me a message. Xiaobian will reply to everyone in time. Thank you very much for your support for the VEVB Wulin website!