#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    soCAL
    Posts
    198
    Rep Power
    26

    Best way for Server Side Form Validation?


    I usually create an error array and upon an invalid field, I add to the array. If there is anything in the array, I generate an appropriate message and take the user back to the original form.

    Another way is to just write little procedures to check each field. Upon an invalid field, that procedure is executed. This method does not capture all the errors at once and usually takes the user back to the same old form for each mistake.

    Anyone else w/ a different/better approach?
  2. #2
  3. Type Cast Exception
    Devshed Supreme Being (6500+ posts)

    Join Date
    Apr 2004
    Location
    OAKLAND CA | Adam's Point (Fairyland)
    Posts
    14,954
    Rep Power
    8617
    Well, make a hash and use a flag. Check each field and if the value is invalid, set the value in the hash to some error identifier (eg Null) and set the flag. At the end, if you have a flag, rewrite the form where you can on the form generation process do the familiar RED font effect on the field name along with any descriptive. The form, naturally, populates the existing (valid) values.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    soCAL
    Posts
    198
    Rep Power
    26
    Originally Posted by medialint
    Well, make a hash and use a flag. Check each field and if the value is invalid, set the value in the hash to some error identifier (eg Null) and set the flag. At the end, if you have a flag, rewrite the form where you can on the form generation process do the familiar RED font effect on the field name along with any descriptive. The form, naturally, populates the existing (valid) values.
    Hmm, I like that approach. Users need to be told what they're missing on the page where they forgot to put the info.

    Thanks. And cool, you're in SF. =)

IMN logo majestic logo threadwatch logo seochat tools logo