SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: cellphone validation problem
-
Jul 1, 2007, 03:14 #1
cellphone validation problem
Hello everyone.
I have this form where a user enters some of his data.
I validate the form for null values, correct email format, and cellphone=10 digits using javascript.
No problem with the validation, except from the cellphone, that no matter what the length, i always get the alert "cellphone not 10 digits".
As i develop with php, js and sql, i test with the php function strlen($cellphone) providing a valid number, and get as a result: 10. So the input seems to be ok.
The script i use is a rather simple one:
if (cellphone.length!=10)
{alert("Cellphone not 10 digits!");cellphone.focus(); return false}
Any ideas of what could be wrong??
Thank you all.
-
Jul 1, 2007, 03:25 #2
- Join Date
- Jun 2004
- Location
- Finland
- Posts
- 703
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
cellphone.value.length ?
-
Jul 1, 2007, 03:33 #3
Sorccu you're absolutely correct!
I've found an example on the web though that didn't use the .value. probably by mistake!
Thanks man!
-
Jul 1, 2007, 03:36 #4
oh and by the way, if i want the null or erroneous field to change colour, is this done through js or css?
-
Jul 1, 2007, 04:07 #5
- Join Date
- Feb 2005
- Location
- Brisbane, Australia
- Posts
- 306
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
CSS, but to make it change without a page reload, you'll need to use Javascript to change the style manually.
-
Jul 1, 2007, 04:20 #6
ok I'll check it out, and see where can i go!!
Thank you all people.
Bookmarks