473,796 Members | 2,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.FormNa me.FieldName.va lue
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 1219
*yandr* wrote in comp.lang.javas cript:
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.FormNa me.FieldName.va lue 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["myFieldNam e"].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.getEle mentById("myFor mId")
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.getEle mentById("myFor mId")


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
2706
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 server with PHP or just use one of the two and if yes which one? I don't want to reinvent the wheel too much. Thanks a lot
6
2871
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 loop through all the forms in a database and pull information about the form (controls and properties). We would need to do the same in our VB.NET project; loop through the project and get the web form's control and property information...
1
4530
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 problem is that if I use the Web Form validation tags, it treats them all as one form (ie...if someone is trying to use the login form, they get an error saying that they have to enter values in the registration form and vice-versa). Any ideas on...
8
579
by: TJS | last post by:
what are folks doing to get around limitation of one server form per page ?
5
2543
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 online). data validation is required on the form. i had looked at using PDF-forms for this.. Adobe's "LifeCyle Forms" would work perfectly. with it one can pass in xml to their webservice & get back PDF-form binaries. however, Adobe's pricing is...
4
2336
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 generate/validate/process forms without hand hacking HTML, however, I also want it to be easy to do! The HTML_Quickform method seems to require more work than it should and whenever you start getting really complicated forms, the hassle starts to...
19
248280
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 this data is essential to any developer. This article is a basic tutorial on how to user HTML Forms, the most common method of data collection. Assumptions - Basic HTML knowledge. - Basic PHP knowledge. HTML Forms A common and simple way of...
1
1456
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 but I see the result). This forms should be filled by user and when filled and when user clickes on the Next button the next page or the same page with filled results and some yellow/red/whatever signs that something was not filled is shown. ...
9
1549
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. To simplify editing forms and to improve readability, webmasters use additional tags and attributes, e.g. <checkbox>, <radio>, arrayname... The compiler of templates changes XML code into (X)HTML with conditional expressions in PHP and variables...
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9535
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10465
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10021
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6800
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5453
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.