Click here to Skip to main content
15,923,006 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
what i want is when user breaks my javascript validation he should not be allowed to move further until he corrects his mistake but my javascript code is allowing him no matters he is not following my validatons . here is my code:
function phval() {
var a;
a = document.getElementById("TextBox5").value;
if (a.length != 10)
{
alert("Enter 10digit number");
return false;
}
else
if (a.charCodeAt(0) == 57 && (a.charCodeAt(1) == 56 || a.charCodeAt(1) == 55) )
{
alert("valid Number ");
return true;
}
else {
alert("Your Number Should Start with either 97 or 98");
return false;

}
}

it works in way that if user enters less than 10 digit in phone no. field alerts, but clicking ok, user is able to all things. what i want is if user number starting is not 97,98 and length is less than 10 then he should not allowed to carry on until and unless he corrects . what can i do.
Posted
Updated 3-Jul-13 0:58am
v3

1 solution

check the given link there you can see validate Phone try this
http://webcheatsheet.com/javascript/form_validation.php[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900