Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
function validPhone(input){
phone=input.value
ansStr = ""
for (n=0;n<phone.length;n++) {
if (isNum(phone.charAt(n))){
ansStr = ansStr + phone.charAt(n)
}
}
if(ansStr.length==0){
input.value=ansStr
return false
}
if (ansStr.length<10 || ansStr.length>10){
alert ("Please enter a valid 10 digit phone number")
input.focus()
input.select()
return false
}
ansStr = "(" + ansStr.substr(0,3) + ") " + ansStr.substr(3,3) + "-" + ansStr.substr(6,4)
input.value=ansStr
}
function isNum(inData){
if (inData >= 0 && inData <= 9 && inData != " "){
return true
}
return false
}
<html>
<body>
<script>
function isPhone(objPhone){
var phoneRegExp=/[^\d]/gi;
var txtPhone=objPhone.value;
txtPhone=txtPhone.replace(phoneRegExp,"");
if (txtPhone.length ==10)
objPhone.value="(" + txtPhone.substr(0,3) + ") " + txtPhone.substr(3,3) + "-" + txtPhone.substr(6,4);
else
alert('Phone number is invalid');
}
</script>
<form name="phoneform" action"abcaction">
<input name="phone" value="123/456/7890" onBlur="isPhone(this);">
<input type="button" name="validate" value="Validate Phone" onClick="isPhone(this.form.phone);">
</form>
</body>
</html>
ptuck said:(ex Phone1 or Phone 2..some folks have multiple numbers, but I only want the first one and delete the rest.)
[b]Phone[/b]
123/456/7890
432-123-1231, 213/312/4354
342.123.1233
(879)123-3124
and so on.