Function for verifying email addresses using JavaScript, and javascript email address
This article introduces a function for verifying email addresses using JavaScript, which is quite reliable.
The function for verifying email addresses using JavaScript. The source code is as follows:
function checkEmail(text) { if( text.match(/qq\.com$/) ) { return -1; } if( ! text.match(/^\w+([._-]\w+)*@(\w+\.)+\w+$/) ) { return false; } return true;}
This article introduces so many functions for verifying email addresses using JavaScript. Thank you!
Javascript email verification problems
Regular Expressions can be used to solve the problem. However, it is easier to divide the mailbox into three input boxes.
The middle @ and. are fixed
Regular:/^ ([\ w-\.] +) @ (\ [0-9] {1, 3 }\. [0-9] {1, 3 }\. [0-9] {1, 3 }\.) | ([\ w-] + \.) +) ([a-zA-Z] {2, 4} | [0-9] {1, 3}) (\]?) $/. Test (mail. value)
Use JavaScript to write a function checkForm () to verify whether the email address is correct
Function f_checkMail (){
Var email = document. myform. email. value;
// @ Symbol exists
Var a = email. indexOf ("@");
// Existence point
Var point = email. indexOf (".");
// @ Exists, points, and points are not adjacent after @
If (a =-1 | point =-1 | point-a <= 1 ){
Alert ("the email format is incorrect. Correct like abc@163.com ");
Document.myForm.txt Mail. select ();
Return false;
}
// @ Cannot be the first character, and the vertex cannot be the last character
If (a = 0 | point = email. length-1 ){
Alert ("the email format is incorrect. Correct like abc@163.com ");
Document.myForm.txt Mail. select ();
Return false;
}
Return true;
}