SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast archive's Avatar
    Join Date
    Mar 2007
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  2. #2
    SitePoint Guru
    Join Date
    Jun 2004
    Location
    Finland
    Posts
    703
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cellphone.value.length ?

  3. #3
    SitePoint Enthusiast archive's Avatar
    Join Date
    Mar 2007
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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!

  4. #4
    SitePoint Enthusiast archive's Avatar
    Join Date
    Mar 2007
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh and by the way, if i want the null or erroneous field to change colour, is this done through js or css?

  5. #5
    SitePoint Addict
    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.

  6. #6
    SitePoint Enthusiast archive's Avatar
    Join Date
    Mar 2007
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok I'll check it out, and see where can i go!!

    Thank you all people.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •