Reputation: 4492
I want to make a custom validation for an phone number input.
var telVal = $("#telefon").val();
if(telVal == '') {
$("#telefon").addClass('eroare png');
hasError = true;
}
This gives me an error if user does not type anything in this input, but I want to check if user types 10 characters. So, the script must be like
if(telVal has 9 characters or more than 10) { do this }
Thank you!
Upvotes: 2
Views: 6288
Reputation: 2611
Plenty of people have done this before - you can probably find some more advanced parsing samples to include in your solution (such as checking for dashes, parentheses, etc.) on sites like this:
http://www.smartwebby.com/DHTML/phone_no_validation.asp
Upvotes: 2