By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,081 Members | 1,342 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,081 IT Pros & Developers. It's quick & easy.

Forms and HTML validation

P: n/a
I am sure the answer is somewhere, but although I have searched for it I
couldn't find it.

I am doing form validation and I am checking each field using
document.FormName.FieldName.value
My problem is that I am using HTML 4 transitional and if I give a name to
the form (<form name="something">) it will not validate. I also can't use
document.Forms[0].FieldName because I have multiple forms in each page.
The ID tag doesn't seem to work either (I mean just replace 'name' with
'id').

So, the question is how can I access the form and validate at the same time?
It would be best if someone can direct me to a tutorial that included
cross-browser compatibility (supporting DOM3 and previous versions).

Thank you very much in advance and sorry if this is stupid.
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
*yandr* wrote in comp.lang.javascript:
I am sure the answer is somewhere, but although I have searched for it
I couldn't find it.

I am doing form validation and I am checking each field using
document.FormName.FieldName.value My problem is that I am using HTML
4 transitional and if I give a name to the form (<form
name="something">) it will not validate.
HTML 4.01 addressed that issue (in 1999):
http://www.w3.org/TR/html401/interac...adef-name-FORM
I also can't use document.Forms[0].FieldName because I have multiple
forms in each page.
document.forms["myFormName"].elements["myFieldName"].value
The ID tag doesn't seem to work either (I mean just replace 'name'
with 'id').
Use of ids for form referencing is not backwards compatible, but to get
a handle on the form:
document.getElementById("myFormId")
So, the question is how can I access the form and validate at the same
time?


Use the amended 4.01 DTD. A list of current DTDs can be found at:
http://www.w3.org/QA/2002/04/valid-dtd-list.html

Best,
--
Andrew Urquhart
- FAQ: http://www.jibbering.com/faq/
- Archive: http://groups.google.com/groups?grou...ang.javascript
- Contact me: http://andrewu.co.uk/contact/
Jul 23 '05 #2

P: n/a
On Tue, 21 Sep 2004 10:09:53 GMT, Andrew Urquhart
<us**************************@com.invalid> wrote:

[snip]
Use of ids for form referencing is not backwards compatible, but to get
a handle on the form:
document.getElementById("myFormId")


Though the forms collection works just as well except, as you say, with
old browsers. Then only named forms can be accessed.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.