Q&A
If I use JavaScript to add validation and other features to my form, can users with non-JavaScript browsers still use the form?
Yes, if you're careful. Be sure to use a Submit button rather than the submit action. Also, the CGI script may receive nonvalidated data, so be sure to include validation in the CGI script. Non-JavaScript users will be able to use the form, but won't receive instant feedback about their errors.
Can I add new form elements "on the fly" or change themfor example, change a text box into a password field?
No. The form elements are set by the HTML code. There are ways to work around this, such as updating the form in a separate frame or layer.
Is there any way to create a large number of text fields without dealing with different names for all of them?
Yes. If you use the same name for several elements in the form, their objects will form an array. For example, if you defined 20 text fields with the name member, you could refer to them as member[0] through member[19]. This also works with other types of form elements.
Why doesn't JavaScript recognize my form elements when I use a table to lay them out?
Some versions of JavaScript do not deal well with forms or scripts within tables when <table> tags are nested. For now, the only solution is to avoid using nested tables.
Is there a way to place the cursor on a particular field when the form is loaded, or after my validation routine displays an error message?
Yes. You can use the field's focus() method to send the cursor there. To do this when the page loads, you can use the onLoad method in the <body> tag. However, there is no way to place the cursor in a particular position within the field.