Common email address IP address English user name validation function
*/
function to check e-mail address like string
function Isemail (s)
{
There must is >= 1 character before @, so we
Start looking at character position 1
(i.e. second character)
var i = 1;
var slength = s.length;
if (slength <= 1) return false;
Look for @
while ((I < slength) && (S.charat (i)!= "@"))
{i++
}
if ((i >= slength) | | (S.charat (i)!= "@")) return false;
else i = 2;
Look for.
while ((I < slength) && (S.charat (i)!= "."))
{i++
}
There must is at least one character after the.
if ((i >= slength-1) | | (S.charat (i)!= ".")) return false;
else return true;
}
Verify that the IP address is used primarily with regular ([0-9]{1,3}) [.] {1,} ([0-9]{1,3}) [.] {1,} ([0-9]{1,3}) [.] {1,} ([0-9]{1,3}) to deal with, because IP is 1.1.1.1 this rule oh, so we just have to conform to the rules on the line. function to check IP addresses like string
function Isipaddress (stripaddress)
{
RegExp = new RegExp ([0-9]{1,3}) [.] {1,} ([0-9]{1,3}) [.] {1,} ([0-9]{1,3}) [.] {1,} ([0-9]{1,3}) ");
Aparts = Regexp.exec (stripaddress);
if (aparts = null)
{
return false;
}
if (aparts.length!= 5)
{
return false;
}
for (nloopcnt = 1; nloopcnt < 5; nloopcnt + +)
{
if (Aparts [nloopcnt] < 0 | | | aparts [NLOOPCNT] > 255)
{
return false;
}
}
return true;
}
User name as long as we first define a abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789-._@ and then traverse the judgment if it does not exist it is not legal.
function Fn_checkloginname (strlogin)
{
Strlogin = trimstring (Strlogin);
var Checkok = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789-._@";
var checkstr = Strlogin;
var allvalid = true;
for (i = 0; i < checkstr.length; i++)
{
ch = checkstr.charat (i);
for (j = 0; J < Checkok.length; J + +)
if (ch = = Checkok.charat (j))
Break
if (j = = Checkok.length)
{
Allvalid = false;
Break
}
}
if (! Allvalid)
{
return (false);
}
if (Checkstr.charat (0) = = '-' | | Checkstr.charat (0) = = '. ' | | Checkstr.charat (0) = = ' _ ')
{
return (false);
}
return (TRUE);
}