The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Validating forms containing tables

After many hours of frustration, I have discovered that any form validation I use comes back with an error 'First Name is undefined'. - The form fields are within tables.
When I use the same validator in a test form *without* tables, it works.

Is there a simple solution? or must I recreate my form without tables. A bit difficult to lay out the form - or is it?

The <form> tag doesn't necessarily need the method, action & name attributes, when validating the form fields through JavaScript or VBScript. While the method & action attributes are for needed to specify where the form will be submitted & using what method(post/get), they can be specified through JavaScript too. And the name attribute just eases the reference to the form fields & eliminates the need of refering the form fields through the forms() array.

Originally Posted by theGWS

When calling the function try using an onClick="validateForm()" instead of the onsubmit= stuff you have.

onSubmit also works as well as onClick. When validating forms before submitting them, its better to use onSubmit rather than onClick on a Submit button, if possible.