I am trying to write code for phone number validation. I need to just check whether it is a numeric value. I used the following code.
var phoneres
function checkphone(int){
var filter=/^[0-9]{3}\-[0-9]{7}$/
if (filter.test(int))
phoneres=true
else {
phoneres=false
}
return (phoneres)
}
if(checkemail(document.getElementById('phone').value) == false) {
alert("Please enter a valid Phone number!");
return false;
}
Even i enter the valid number example 111-1234567 it displays "Please enter a valid Phone number!".
How can i correct that?
You are calling the
checkemailinstead ofcheckphonefunction