Form Validation Help

Discussion in 'JavaScript' started by sweetragini, Mar 8, 2008.

  1. #1
    I have a form with 3 text boxes for name, phone, email address. What I want is only alphabets are allowed in name only numbers are allowed in phone and email is allowed in email box?

    I have a submit button, when I click that button it should check above validations.

    Can anyone help me with it?
     
    sweetragini, Mar 8, 2008 IP
  2. Ares

    Ares Member

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #2
    I think this would solve your problem :
    codedcode.com/javascript/javascript-validation.asp
     
    Ares, Mar 8, 2008 IP
  3. roy.laurie

    roy.laurie Peon

    Messages:
    51
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You should RegExp.

    Put these tests in conditionals to verify...
    
    name.match(/^[a-zA-Z]+$/)
    phone.match(/^[0-9]+$/)
    email.match(/^[a-zA-Z\.\-]+\@[a-z\.\-]+\.(?:com|net|org|biz|info|tv|mobi|name)$/)
    
    Code (markup):
    Note that the email match isn't perfect.
     
    roy.laurie, Mar 9, 2008 IP