JavaScript mailbox URL Regular validation code

Source: Internet
Author: User
Web page effect email address regular validation code

function Checkurl () {
var maxlength = 50;
var url = $ ("#tbcommentauthorurl"). Val ();

if (Url.length = = 0) {
Commenturlisvalid = true;
return true;
}
else if (Url.length > MaxLength) {
$ ("#tip_url"). HTML ("Home address does not allow more than" + MaxLength + "characters!) ");
Commenturlisvalid = false;
return false;
}
else if (Url.indexof ("http://")!=0 | | url.indexof (".") < 0) {
$ ("#tip_url"). HTML ("Home address to start with" http://);
Commenturlisvalid = false;
return false;
}
else{
$ ("#tip_url"). HTML ("");
Commenturlisvalid = true;
return true;
}
}

function Checkemail () {
var email = $ ("#tbcommentemail"). Val ();
if (email.length>0) {
var regexp = new RegExp ("w+@" (w|-) +.) +[a-z]{2,3} ");
if (!regexp.test (email)) {
$ ("#tip_email"). HTML ("Please enter the correct email address!");
Commentemailisvalid = false;
}
else{
Commentemailisvalid = true;
$ ("#tip_email"). HTML ("");
}
}
else{
Commentemailisvalid = true;
$ ("#tip_email"). HTML ("");
}
}

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.