<script language = ' JavaScript ' >
Check for English
function Checkchar ()
{
var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for (i=0 i < document.form.aaa.value.length; i++)
{
var Checkchar = document.form.aaa.value.charAt (i);
Checkchar = Checkchar.touppercase ();
if (Letters.indexof (checkchar) = =-1)
{
Alert ("input type must be English!") ");
return false;
}
}
}
Checksum is a number
function Checknum (p)
{
if (p = = "")
{Alert ("Input cannot be empty!") ");
return false;
}
var L = p.length;
var count=0;
for (var i=0; i<l; i++)
{
var digit = P.charat (i);
if (digit = = ".")
{
++count;
if (count>1)
{Alert ("input type must be a number!") ");
return false;
}
}
else if (digit < "0" | | digit > "9")
{Alert ("input type must be a number!") ");
return false;
}
}
return true;
}
Verify IP address format
function Checkip ()
{
var scount=0;
var ip = document.form3.ccc.value;
var iplength = ip.length;
var letters = "1234567890.";
for (i=0 i < document.form3.ccc.value.length; i++)
{
var Checkchar = document.form3.ccc.value.charAt (i);
if (Letters.indexof (checkchar) = =-1)
{
Alert ("The IP address format is not!!, you can only enter numbers and". ", the format is XXX.XXX.XXX.XXX for example: 192.168.0.1");
Document.form3.ccc.value= "";
Document.form3.ccc.focus ();
return false;
}
}
for (var i = 0;i<iplength;i++)
(Ip.substr (i,1) = = ".")? Scount++:scount;
if (scount!=3)
{
Alert ("The IP address format is not correct!, you can only enter numbers and". ", the format is XXX.XXX.XXX.XXX for example: 192.168.0.1");
Document.form3.ccc.value= "";
Document.form3.ccc.focus ();
return false;
}
if (str1== "" | | str2== "" | | str3== "" | | STR4 = "")
{Alert ("Number cannot be empty!") Format for XXX.XXX.XXX.XXX For example: 192.168.0.1 ");
Document.form3.ccc.value= "";
Document.form3.ccc.focus ();
return false;
}
if (str1< 0 | | | str1 >255)
{Alert ("number range is 0~255! ");
Document.form3.ccc.value= "";
Document.form3.ccc.focus ();
return false;
}
else if (str2< 0 | | str2 >255)
{Alert ("number range is 0~255! ");
Document.form3.ccc.value= "";
Document.form3.ccc.focus ();
return false;
}
else if (str3< 0 | | str3 >255)
{Alert ("number range is 0~255! ");
Document.form3.ccc.value= "";
Document.form3.ccc.focus ();
return false;
}
else if (str4< 0 | | STR4 >255)
{Alert ("number range is 0~255! ");
Document.form3.ccc.value= "";
Document.form3.ccc.focus ();
return false;
}
Verifying phone numbers
function Checkphone ()
{
var letters = "1234567890,";
for (i=0 i < document.form4.ddd.value.length; i++)
{
var Checkchar = document.form4.ddd.value.charAt (i);
if (Letters.indexof (checkchar) = =-1)
{
Alert ("Phone number can only be a number or comma!") ");
return false;
}
}
}
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.