Blog

Javascript-Check IP Address using Regex

By Ghanashyam Nayak Blogs | JavaScript Apr 15, 2011
This code shows you that how you can check the user's given value is Valid IP Address or not using javascript on button click event.

  

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

 

<html>

<head>

<title>Sample Code</title>

<script type="text/javascript">

function CheckIPAddress(MyIPAddress)

{

       var CheckIP = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;

       if(CheckIP.test(MyIPAddress))

       {

             alert("Your IP Address Is Valid.");

       }

       else

       {

             alert("Your IP Address Is Not Valid.");

       }

}

</script>

</head>

<body bgcolor=#00ff00 alink=blue vlink=blue>

<FORM name="windowEvent">

       IP Address : <input type="text" name="txtipaddress" />

       <input type="button" value="Check" name="btnIPAddress" onClick="CheckIPAddress(txtipaddress.value)" />

</FORM>

</body>

</html>


COMMENT USING

PREMIUM SPONSORS

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs