Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- JavaScript JumpStart #2 - form validation


ShawnR - 10:22 pm on Jun 19, 2003 (gmt 0)


"... use the required attribute on all form elements... The only issue I have with it is that my code does not validate as XHTML Strict because of the required attribute. Anyone know of a way around that? ..."

The way I do it is to have the form element name

e.g.
Not required:
<input type="text" name="textbox1" ...

Required:
<input type="password" name="
required_password1" ...

Then I loop through all of the form's elements, testing for whether the name starts with "required", and if so I use a switch to handle the different types of form elememnts.


Thread source:: http://www.webmasterworld.com/javascript/437.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com