Java Script phone number entered by person should be in numeric only. code required!

Java Script phone number entered by person should be in numeric only. code required!

i am using javascript coding on jsp page. i want that the phone number entered by person should be in numeric only..can i get code for it?

View Answers

April 29, 2012 at 11:08 PM

will anyone reply????


April 30, 2012 at 1:44 PM

<html>
<script>
function validate(){
 var ph=document.getElementById('phone').value;
var regExpObj = /^[0-9]+$/;
 if(ph==""){
alert("Enter Phone Number!");
}
 else if(regExpObj.exec(ph) == null){
        alert('Invalid Phone Number!');
        return false;
    } else {
     return true;
    }
}
</script>
<form id="form" method="post" onsubmit="javascript:return validate();">
Phone Number:<input type="text" id="phone"><br>
<input type="submit" value="Submit">
</form>
</html>

May 2, 2012 at 12:15 AM

thankyouuuuu...it was so helpful :)









Related Tutorials/Questions & Answers:

Ads