473,395 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Forms and HTML validation

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
2 1201
*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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: varois83 | last post by:
Hi Newbie here. I have been working on creating a guestbook for my site as practice and am learning a lot. Do you guys validate your forms first on the client with javascript and then on the...
6
by: ALthePal | last post by:
Hi, I'm not sure if we are able to or even how to loop through the web forms in a VB.NET project during design time. In MSAccess we are able to go through the database -> forms collection and...
1
by: iMedia User | last post by:
I have a site where I want to use the Web form validators in two separate forms on a single page. One form allows existing users to log in while the second one allows new users to register. The...
8
by: TJS | last post by:
what are folks doing to get around limitation of one server form per page ?
5
by: matt | last post by:
hello, i am on an interesting project. in this project, i have to create dynamic data-entry forms for offline-users to fill out, save locally, and eventually postback to our app (when back...
4
by: Andrew Taylor | last post by:
I've been struggling for a long time with HTML_Quickform from PEAR. The concept is ideal, but, the implementation is (IMHO) a bit of a kludge. As a developer I want a quick and easy way to...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
1
by: Sergei Riaguzov | last post by:
Hi. I haven't written in PHP too much so I think I should ask how my problem can be solved "the right way". I'm having some forms (actually this is not my code, and actually I haven't got it yet...
9
by: WebCM | last post by:
I need a solution for CMS. I would like to edit and create FORMS easily, especially list of settings. Which is better and why? $$ XML or HTML $$ Forms occur in View layer - in presentation file....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.