On Tue, Jun 30, 2009 at 11:21:03PM -0400, Phpster wrote: > On Jun 30, 2009, at 10:48 PM, Paul M Foster <paulf@xxxxxxxxxxxxxxxxx> > wrote: > <snip> >> >> FWIW, I've had to do this exact thing with regard to form validation, >> except I'm not looping. Check each condition, and if it fails, never >> mind validating the rest of the fields. >> > > Isn't that a little rough on the user? Wouldn't a better user > experience be to check all the fields and report all errors back to > the user in one pass, rather than after each element that fails? <blush> Well, yes. Early on I tended to do it this way, but I made my error handling more sophisticated over time. Actually, where I do something like this now is on some blog software I wrote. There are numerous fields to be filled out, and if all are filled out correctly, it updates a database and dumps some files to disk. At each field check, I increment an error count variable if the user screws up. And before I check each field, I check the error count. If there are errors, then I may not update the database and dump the files, so there's no point in checking the contents of certain fields. For example, if the user didn't provide a title for the post, I'm not going to go through the process of XSS checking on their post content, since I'm not going to store it until they give me a title. I'll report to them on the missing fields, though, and allow them to repair. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php