Verify the email core code as follows
The code is as follows |
Copy Code |
function Isemail (input) { var reg =/^w+ (-w+) | (. w+)) *@[a-za-z0-9]+ ((. | -) [a-za-z0-9]+] *. [a-za-z]+$/; return reg.test (input); } Cases <script type= "Text/javascript" defer= "defer" > function Isemail (stremail) { if (/^w+ (-w+) | (stremail.search) | (. w+)) *@[a-za-z0-9]+ ((. | -) [a-za-z0-9]+] *. [a-za-z0-9]+$/)!=-1) return true; Else Alert ("The email you entered is not valid, please re-enter!"); }
</script> <body> <form id= "Form1" runat= "Server" > <div>
<asp:textbox id= "TextBox1" runat= "Server" onblur= Javascript:return isemail ($ (this). Val ()); ></asp:TextBox> <asp:button id= "Button1" runat= "Server" text= "button" onclick= "Button1_Click"/> </div> </form> |
Verify the phone number
The code is as follows |
Copy Code |
function IsMobile (input) { var reg=/^ (13[0-9]|15[0|3|6|7|8| 9]|18[8|9]) d{8}$/; return reg.test (input); } |
Instance
The code is as follows |
Copy Code |
<script type= "Text/javascript" > function Checkmobile () { var smobile = Document.mobileform.mobile.value if (!) ( /^1[3|5][0-9]d{4,8}$/.test (Smobile))) { Alert ("Not a full 11-digit cell phone number or the correct number of the top seven"); Document.mobileform.mobile.focus (); return false; } } </script> <form action= "" Name= "Mobileform" method= "POST" onsubmit= "return Checkmobile ();" > <input name= "mobile" class= "TDC" size= "a" maxlength= "one" > <input name= ' action ' type= ' hidden ' value=mobile> <input ' class= bdtj ' name=b1 type=submit ' value= ' query > </FORM> |
Verifying phone number Codes
The code is as follows |
Copy Code |
function Isphone (input) { var reg=/^ ([0+]d{2,3}-)? ( 0d{2,3})-(d{7,8}) (-(D{3,})? $/; return reg.test (input); } |
Example
The code is as follows |
Copy Code |
function Checkphone (phone) { //Verify phone number, including 153,159 segment If (phone== "") { Alert ("Phone number cannot be empty!") "); return false; } if (phone!=" ") { & nbsp; var p1 =/^ ([0+]d{2,3}-)? ( 0d{2,3})? (d{7,8}) (-(D{3,})?$/; var me = false; if (p1.test (phone)) me=true; & nbsp if (!me) { //alert (' Sorry, www.111cn.net the phone number you entered has an error. Between area code and phone number please use-split '); return false; } }& nbsp; Return true; } |