Home > Web Front-end > JS Tutorial > jquery verifies whether the mobile phone number and email format are correct sample code_jquery

jquery verifies whether the mobile phone number and email format are correct sample code_jquery

WBOY
Release: 2016-05-16 17:27:49
Original
1609 people have browsed it
Copy code The code is as follows:

//jquery verification email
function checkSubmitEmail() {
if ($("#email").val() == "") {
//$("#confirmMsg").html("The email address cannot be Empty! ");
alert("Email cannot be empty!")
$("#email").focus();
return false;
}
if (!$("#email").val().match(/^w ((-w )|(.w ))*@[A-Za-z0-9] ((.|-)[ A-Za-z0-9] )*.[A-Za-z0-9] $/)) {
alert("Email format is incorrect");
//$("#confirmMsg") .html("The email format is incorrect! Please re-enter!");
$("#email").focus();
return false;
}
return true;
}

//jquery verification mobile number
function checkSubmitMobil() {
if ($("#mobile").val () == "") {
alert("Mobile phone number cannot be empty!");
//$("#moileMsg").html("Mobile phone The number cannot be empty! ");
$("#mobile").focus();
return false;
}

if (!$(" #mobile").val().match(/^(((13[0-9]{1})|159|153) d{8})$/)) {
alert("Mobile number format Incorrect! ");
//$("#moileMsg").html("The mobile phone number format is incorrect! Please re-enter!");
$("#mobile").focus();
return false;
}
return true;
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template