Several common string verification in CRP

Source: Internet
Author: User

Several common string verification in CRP

<! -- Writed by Zhong @ IECN 2004.3.26 -->

<Script language = "javascript">
Var reIp =/^ ([01]? D {1, 2} | 2 [0-4] d | 25 [0-5]) (. ([01]? D {1, 2} | 2 [0-4] d | 25 [0-5]) {3} $/; // IP
Var reEml =/^ [w-.] + @ [a-z0-9] + (-[a-z0-9] + )? (. [A-z0-9] + (-[a-z0-9] + )?) *. [A-z] {2, 4} $/I; // email
Var reTel =/^ (d {2, 3 }-)? D {2, 5 }-)? [2-9] d {6, 7} (-d {2, 5 })? $ // Phone number
Var reMbl =/^ 13 [0135-9] d {8} $/; // mobile phone number
Var reHttp =/^ http: // [a-z0-9] + (-[a-z0-9] + )? (. [A-z0-9] + (-[a-z0-9] + )?) *. [A-z] {2, 4 }(/? |/. +) $/I; // Http address
Var reNum =/^ -? D + (. d + )? $/; // Numeric value
Var reIdc =/^ d {15} (d {2} [a-z0-9])? $ // ID card
</Script>

<Table>
<Tr>
<Td align = "right"> IP: </td>
<Td> <input id = "ipInput"/> <input type = "button" value = "Check" onclick = "alert (reIp. test (ipInput. value); "/> (for example, 123.123.123.123) </td>
</Tr>
<Tr>
<Td align = "right"> Email: </td>
<Td> <input id = "emailInput"> <input type = "button" value = "Check" onclick = "alert (reEml. test (emailInput. value); "> (such as: xxx@iecn.net </a> </td>
</Tr>
<Tr>
<Td align = "right"> Tel: </td>
<Td> <input id = "telInput"/> <input type = "button" value = "Check" onclick = "alert (reTel. test (telInput. value); "/> (for example, 86-10-12345678-123) </td>
</Tr>
<Tr>
<Td align = "right"> mobile phone number: </td>
<Td> <input id = "mblInput"/> <input type = "button" value = "Check" onclick = "alert (reMbl. test (mblInput. value); "/> (for example, 13012345678) </td>
</Tr>
<Tr>
<Td align = "right"> Http address: </td>
<Td> <input id = "httpInput"/> <input type = "button" value = "Check" onclick = "alert (reHttp. test (httpInput. value); "/> (such as: http://www.iecn.net) </td>
</Tr>
<Tr>
<Td align = "right"> value: </td>
<Td> <input id = "numInput"/> <input type = "button" value = "Check" onclick = "alert (reNum. test (numInput. value); "/> (for example, 123, 123.4,-0.123) </td>
</Tr>
<Tr>
<Td align = "right"> ID card: </td>
<Td> <input id = "idcInput"/> <input type = "button" value = "Check" onclick = "alert (reIdc. test (idcInput. value); "/> (for example, 123456197601018888) </td>
</Tr>
</Table>
<Br/>
Note: <br/>
1. The IP address is strictly verified. <br/>
2. the part before "@" in the E-mail address is not very definite. If you do not want to "mistaken kill", set "[w-.] + "to" [^ @] + "; <br/>
3. the telephone number is basically strictly verified. The international area code, domestic area code, and extension code can have or do not exist. The number of digits can be 7 or 8 without considering the specific situation; <br/>
4. Mobile phone numbers have been strictly verified. <br/>
5. The Http address type can be changed according to the situation, such as "[http | ftp]". The domain name is verified as strictly as possible, and the path is not verified. <Br/>
6. The value is strictly verified. <br/>
7. The ID card only determines the number of digits (15 or 18 digits, and 18 digits can contain uppercase letters ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.