Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


nikita anand
Java Script phone number entered by person should be in numeric only. code required!
3 Answer(s)      2 years and 5 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:
Advertisements
 

 

 

DMCA.com