form validation best practice

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tedqn@yahoo.com

    #1

    form validation best practice

    I usually use the onSubmit event to validate form because in case an
    error is generated (not because user misses a field), the submit will
    continue. Current I have a form in which I have to do a hidden iframe
    background process to validate server side. If sucess then the iframe
    page would generate the script to subit form. I don't like it because
    if there's an error, the form won't be submitted at all even though
    it's not the user's fault. I'd like your ideas on how to handle form
    validations. Thanks.

  • Danny

    #2
    Re: form validation best practice


    Depends on the scenario, js can do data checks just fine, so, it really
    depends, but onsubmit is a popular way to use. Server sided submits for
    checking, and loads the result either if it validates or not, is uses the
    client bandwidth regardless to do a page request and page serving, there's
    timing and server load, while using it client sided, there isn't any
    delays due to session transactions, if the user makes a mistake, it's let
    known right away and addressed right there. You could do a browser check
    server sided in order to spot older browsers and do server sided for them,
    else, use js.

    Danny

    On Sun, 19 Jun 2005 15:18:08 -0700, <tedqn@yahoo.co m> wrote:
    [color=blue]
    > I usually use the onSubmit event to validate form because in case an
    > error is generated (not because user misses a field), the submit will
    > continue. Current I have a form in which I have to do a hidden iframe
    > background process to validate server side. If sucess then the iframe
    > page would generate the script to subit form. I don't like it because
    > if there's an error, the form won't be submitted at all even though
    > it's not the user's fault. I'd like your ideas on how to handle form
    > validations. Thanks.
    >[/color]



    --
    Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

    Comment

    • Michael Winter

      #3
      Re: form validation best practice

      On 18/06/2005 03:24, Danny wrote:

      Please don't top-post.

      [snip]
      [color=blue]
      > You could do a browser check server sided in order to spot older
      > browsers and do server sided for them, else, use js.[/color]

      Why bother? User submissions should always be checked on the server,
      whether the client could perform the checks itself or not.

      A client-side script is in a better position to determine whether it can
      can perform validation. If it can't, the server will still perform the
      checks anyway, so it's not a big deal, just a little more network traffic.

      Mike

      --
      Michael Winter
      Replace ".invalid" with ".uk" to reply by e-mail.

      Comment

      • Richard Cornford

        #4
        Re: form validation best practice

        Danny wrote:
        <snip>[color=blue]
        > ... . You could do a browser check server sided in
        > order to spot older browsers ... .[/color]
        <snip>

        And how do you propose doing that?

        [Pays out rope with the label "User Agent header" attached to the end.]
        [color=blue]
        > On Sun, 19 Jun 2005 15:18:08 -0700, <tedqn@yahoo.co m> wrote:[/color]
        <snip>

        Please do not top-post to comp.lang.javas cript, se the FAQ:-

        <URL: http://www.jibbering.com/faq/ >

        Richard.


        Comment

        Working...