Re: best way to handle required form fields
| From: | Brent Baisley | Date: | Wed, 14 May 2003 12:38:18 +0000 |
| Subject: | Re: best way to handle required form fields | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-147574@lists.php.net to get a copy of this message | ||
I use both Javascript alerts and server side validation for security reasons. I use Javascript simply from a user interface point of view. You shouldn't rely on client side validation for security since anyone can submit any URL to your system.
I typical have one page that handles view, new, edit and save functions. I first check if the operation is a save. If it is, I do a validation on the data. If validation fails I update an error variable with an error message and change the operation to new or edit, whatever it was before. The page then continues to load as before, including echoing the error message which now contains something whereas before it didn't.
That's the simple way of doing it. I also use red hilighting on the fields, but I use templates which makes it much easier.
On Tuesday, May 13, 2003, at 08:20 PM, <daniel@electroteque.org> wrote:
hi there i was wondering what would be the most ideal way to handle required form fields say if they were empty and are required , should i do a check and send an error and return to the page with the required fields in red or would a javascript alert box (ugly) be ok ? reason being my prefered way would be sending an error although with my previous issue with custom error handlers might be tedious :| -- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577