JavaScript Common authentication function IP phone, mailbox domain name Chinese digit

Source: Internet
Author: User


*/

function Isip (data) {
var regip=/^ (1?d?d| ( 2 ([0-4]d|5[0-5])).) {3} (1?d?d| (2 ([0-4]d|5[0-5])) $/;
return regip.test (data);
}
function IsMobile (MNO) {
var regmobile=/^0?1 (3|5|8) d{9}$/;
Return Regmobile.test (MNO);

}

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
return false;
}
function Isdomain (strdomain) {
var domainreg=/^ ([w-]+) | ( [u4e00-u9fa5]+)] (.) (([w-]+) | ([w-]+) ([.]?) ([w-]+) | ([u4e00-u9fa5]+)] [w.-]*$/;

Return Domainreg.test (Strdomain);


}
function Ischinese (text) {
Whether to contain Chinese
var dhinesereg=/^.*[u4e00-u9fa5]+.*$/;
return dhinesereg.test (text);

}
function Isen (text) {
for (i=0;i<text.length;i++)
if (Text.charcodeat (i) >255) {
Alert ("Sorry! Submission failed," +text+ "cannot contain Chinese characters!");
Data.focus ();
Data.select ();
return false;
}
return true;
}
function Isnum (number) {
var i,str1= "0123456789";
if (number==null| | number== "") return false;
for (i=0;i<number.length;i++) {
if (Str1.indexof (Number.charat (i)) ==-1) {
return false;
Break
}
}
return true;
}
function IsNull (text) {
if (text== "") {
Alert ("Sorry! Commit failed," +text+ "cannot be empty!");
Data.focus ();
return false;
}
else{
return true;}
}
function Hasgb (text) {
for (i=0;i<text.length;i++)
if (Text.charcodeat (i) >255) return true;
Alert ("Sorry! Submission failed," +text+ "must contain Chinese characters!");
Data.focus ();
Data.select ();
return false;
}
function Validchar (text) {
Charlist= "&^%$#@!* () ~ ' +";
for (i=0;i<charlist.length;i++)
if (Text.indexof (Charlist.charat (i))!=-1) {
Alert ("Error," +text+ "cannot contain special symbols [" +charlist.charat (i) + "]!");
Data.focus ();
Data.select ();
return false;
}
return true;
}

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.