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

 
 


nikita anand
Java Script phone number entered by person should be in numeric only. code required!
3 Answer(s)      a year 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?

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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.