Common JS User Verification function

Source: Internet
Author: User

Determine if the contents of the input box are a valid E_Mail address
function Checkisemail (obj,msg)
{
var reg=/^ ([a-za-z0-9_]*) @ ([a-za-z0-9_]*). ([a-za-z0-9]{2,3}) $/
if (!reg.exec (Obj.value))
{
Alert (msg);
Obj.focus ();
return false;
}
return true;
}

Determine if the contents of the input box is a valid ID number
function Checkisid (obj,msg)
{
var reg=/^ ([0-9]{18}) | ([0-9]{15}) $/
if (!reg.exec (Obj.value))
{
Alert (msg);
Obj.focus ();
return false;
}
return true;
}

Determine if the contents of the input box are numbers
function Checkisnumeric (obj,msg)
{
var reg=/^[0-9]*$/
if (!reg.exec (Obj.value))
{
Alert (msg);
Obj.focus ();
return false;
}
return true;
}

Determines whether the entered content is in the correct format of the date
function Checkisdate (obj)
{
var reg=/^ ([0-9]{2,4})/([0-9]{1,2})/([0-9]{1,2}) $/
if (!reg.exec (Obj.value))
{
Alert ("Enter date n format in the following format: 2000/05/25");
Obj.focus ();
return false;
}
return true;
}

Determines if the entered content is in the correct format date (start time)
function Checkisdatese (obj)
{
var reg=/^ ([0-9]{2,4})/([0-9]{1,2}) ~ ([0-9]{2,4})/([0-9]{1,2}) $/
if (!reg.exec (Obj.value))
{
Alert ("Please enter the date n format in the format: 2000/05~2001/11");
Obj.focus ();
return false;
}
return true;
}

Determine if it is a correct user name: Name + number + Underline
function Checkisusername (obj)
{
var reg=/^[0-9a-za-z_]*$/
if (!reg.exec (Obj.value))
{
Alert ("You enter a user name that contains illegal characters!") User names can only be numbers, underscores _, and uppercase and lowercase letters. ");
Obj.focus ();
return false;
}
return true;
}

function Delcheck (str) {
return confirm (str+ "n) are you sure you want to do the delete operation? Delete will not be restored, if not, please press Cancel! ");
}

function Linebr (obj)
{
obj.value+= "<br>";
}

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.