August 26th, 2004, 02:35 AM
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?
August 26th, 2004, 09:29 PM
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.
August 27th, 2004, 04:46 PM
Hmm, I like that approach. Users need to be told what they're missing on the page where they forgot to put the info.
Originally Posted by medialint
Thanks. And cool, you're in SF. =)