I want to check the cell number using JavaScript .
Here is my code.
if(number.value == "") { window.alert("Error: Cell number must not be null."); number.focus(); return false; } if(number.length != 10) { window.alert("Phone number must be 10 digits."); number.focus(); return false; }
Here is the problem, when I submit the form without entering the phone number, it shows that the error cell number should not be zero. It works great.
When I submit a form with a cell number less than 10 digits, it shows that the phone number should be 10 digits. It is also beautiful.
The problem is that I submit the form with 10 digits and then shows the error phone number should be 10 digits.
Please help me. Thanks.
And you also need a verification code for cell numbers only.
source share