nikita anand
Java Script phone number entered by person should be in numeric only. code required!
3 Answer(s)      3 years and 4 months ago
Posted in : JavaScript Questions

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?

Advertisement
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: