JS detects if the input box content is a legitimate IP address

Source: Internet
Author: User

<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> Check if it is an IP address </TITLE>
<meta name= "Generator" content= "EditPlus" >
<meta name= "Author" content= "" >
<meta name= "Keywords" content= "" >
<meta name= "Description" content= "" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
</HEAD>
<BODY>
&LT;TITLE&GT;IP address legality Verification JS code-</title>
Please enter IP address: <input type= "text" id= "IP" >
<input type= "button" onclick= "Checkip ()" value= "Verify" >
</BODY>
</HTML>
<script language= "JavaScript" >
function Checkip ()
{
obj = document.getElementById ("IP"). Value;
IP Address
var exp=/^ (\d{1,2}|1\d\d|2[0-4]\d|25[0-5]) \. (\d{1,2}|1\d\d|2[0-4]\d|25[0-5]) \. (\d{1,2}|1\d\d|2[0-4]\d|25[0-5]) \. (\d{1,2}|1\d\d|2[0-4]\d|25[0-5]) $/;
var reg = Obj.match (exp);
if (reg==null)
{
Alert ("IP address is not legal!") ");
}
Else
{
Alert ("IP address is legal!") ");
}
}
</script>

JS detects if the input box content is a legitimate IP address

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.