Mobile No Validation javascript

How to validate mobile no in java script.

<HTML>
<head>
    <script>
    function ToCellValidate(objText)
    {
        if(objText.value!="")
        {
        if(objText.value.length < 9 || objText.value.length > 15 || objText.value.search(/[^0-9\-()+]/g) != -1 )
        {
        alert('Please enter valid mobile number');
        objText.focus();
        objText.value.value="";
        return false;
        }
        else{
        alert("valid mobile number");
        return true;
        }
        }
    }
    </script>
</head>
 <BODY>
  <input type="text" name="text" id="text"><br/><input type="submit" name="validate" value="validate" onclick=ToCellValidate(document.getElementById('text'));>
 </BODY>
</HTML>

Comments

  1. Give javascript code for telephone validation and income validation

    ReplyDelete

Post a Comment

Recent Post

Recent Posts Widget

Popular posts from this blog

Capture image from webcam java code, examples

Shallow Copy Deep Copy Java example

Database Connection using NODE JS example