As not everybody is using a javascript-capable browser, and not everybody with one even has javascript turned on, I'd like to recommend an alternative. Process the page with PHP, and if there's anything missing/incorrect, re-output the page with little red asterisks or whatever, maybe some instructions.
It's pretty easy to do. Setup a function that outputs the page. Now, when the user submits the form, validate all the data. If something is wrong, call the function that outputs the page, and pass an array of fields with errors. The function that outputs it should see if that array is empty, and if not, output a red asterisk or something before every errored field.
I can provide further help if you need it. The advantage is, <b>everybody</b> will be able to use your form.
|