How to used javascript for form validation?

Discussion in 'JavaScript' started by raspms, Mar 6, 2012.

  1. #1
    i am using one webform for customer using asp.net .i want to check all fields are requied while inserting a
    record in database.. means i want to validate customer emailid in proper format..mobile number should be in numeric only..
    can i used javascript for that? and how can i used that one ?
     
    raspms, Mar 6, 2012 IP
  2. Co1dFusion

    Co1dFusion Peon

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    yes you can use javascript something along the lines of: Search "javascript form validation"
     
    Co1dFusion, Mar 7, 2012 IP
  3. GMF

    GMF Well-Known Member

    Messages:
    855
    Likes Received:
    113
    Best Answers:
    19
    Trophy Points:
    145
    #3
    Yes, you could use javascript for form validation but it is not recommended because one can easily disable javascript. You should use a server side scripting language for that.

    I see you are using asp. Well, I don't know how to code in asp, but it should not be that hard. Plenty tutorials around the web, just found one..

    http://www.w3schools.com/asp/asp_inputforms.asp
    Code (markup):
     
    GMF, Mar 7, 2012 IP
  4. Co1dFusion

    Co1dFusion Peon

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Although it as not as secure as PHP or ASP, you can still use JavaScript to check that inputs have been filled out. If you want to use PHP the isset() function might come in handy.
     
    Co1dFusion, Mar 7, 2012 IP
  5. Co1dFusion

    Co1dFusion Peon

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Also the noscript tag can compensate for JS being turned off
     
    Co1dFusion, Mar 7, 2012 IP
  6. rkstech

    rkstech Active Member

    Messages:
    195
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    73
    #6
    search on google loads of help, for numbers only try the isNan function as well
    or use regular expressions
     
    rkstech, Mar 7, 2012 IP
  7. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #7
    yes you can.. try to check this site for a sample of the form validation.. http://www.tizag.com/javascriptT/javascriptform.php
     
    JohnnySchultz, Mar 8, 2012 IP