Loading
View RSS Feed

Angad Kumar Shukla's blog

Phone Number Validation Using Javascript

Rating: 23 votes, 4.61 average.
Code:
<html>
<head>
<title></title>

<script language="javascript">
function Validate()
{
        var x = document.sform.phone_no.value;
       
        if (x==null || x=="")
 	 {
 		 alert("Phone no. cannot be left blank");
 		 return false;
 	 }       

       	 if(isNaN(x)|| x.indexOf(" ")!=-1)
	{
              			alert("Enter numeric value");
			return false;
                }
       			 if (x.length > 10)
			{
                			alert("enter 10 characters"); 
				return false;
          			 }
       
}

</script>
</head>
<body>

    <form name="sform" action="phsuccess.html" method="post">
     Phone Number<input name="phone_no" type="text" id="phone_no" />
<input type="submit" name="Submit" value="Go" onclick="return Validate()"/>
      </form>
  </table> 
</body>
</html>

Submit "Phone Number Validation Using Javascript" to Digg Submit "Phone Number Validation Using Javascript" to del.icio.us Submit "Phone Number Validation Using Javascript" to StumbleUpon Submit "Phone Number Validation Using Javascript" to Google

Categories
Java , Web Design

Comments




Disclaimer: Users of techforum4u.com are responsible for ensuring that any material they post (article, blog posts, images or other mulitimedia content) does not violate or infringe upon the copyright, patent, trademark, or any personal or proprietary rights of any third party, and is posted with the permission of the owner of such rights.Anyone who violates these rules may have their access privileges removed without warning.