Hi,
how can I check if an input field in a form is defined? I create the field
dynamically, so it could or could not be in the form.
TIA. 6 12357
Xerxes wrote: Hi, how can I check if an input field in a form is defined? I create the field dynamically, so it could or could not be in the form.
if (document.forms['formName'].elements['elementName']) {
// Element name is defined
}
Instead of formName and elementName you can also use indexes.
JW
I am hving the problem inside a function that is validating form fields.
It takes the form name as argument. I used your example, with some
modifications but it does not seem to work:
function validate(theFor m){
....
if (theForm.FR) { // FR is the field name, which is a group of radio
buttons
if (!getRadioButto nChecked(theFor m.FR)) {
alert("Please make a selection ....")
return false;
}
}
....
}
Then in the form:
<form name..... onSubmit="retur n validate(this)>
....
<?php
if (some condition)
<input name="FR" type="radio" value=""
....
?>
So, the function getRadioButtonC hecked is not supposed to be called if FR is
not defined, but it does get called and it chokes if the field is not
defined.
Isn't there something like "isdefined" or "isset" function in javascript?
Thanks.
"Janwillem Borleffs" <jw@jwscripts.c om> wrote in message
news:40******** *************** @news.wanadoo.n l... Xerxes wrote: Hi, how can I check if an input field in a form is defined? I create the field dynamically, so it could or could not be in the form.
if (document.forms['formName'].elements['elementName']) { // Element name is defined }
Instead of formName and elementName you can also use indexes.
JW
Xerxes wrote: function validate(theFor m){ ... if (theForm.FR) { // FR is the field name, which is a group of radio
[...] Isn't there something like "isdefined" or "isset" function in javascript?
Sure, you can use typeof to see if the object doesn't evaluate to
'undefined', but the code in my previous reply has the same result with a
shorter notation.
Your problem, however, is that you are not accessing the element through the
elements collection, try:
if (theForm.elemen ts['FR']) {
...
}
JW
Hi,
You can try "undefined"
....
if ((theForm.FR.va lue=="undefined ")) {
alert("Please make a selection ....")
return false;
}
Kien
"Xerxes" <as******@hotma il.com> wrote in message news:<39******* *************** ********@news.t eranews.com>... I am hving the problem inside a function that is validating form fields. It takes the form name as argument. I used your example, with some modifications but it does not seem to work:
function validate(theFor m){ ... if (theForm.FR) { // FR is the field name, which is a group of radio buttons if (!getRadioButto nChecked(theFor m.FR)) { alert("Please make a selection ....") return false; } } ... }
Then in the form: <form name..... onSubmit="retur n validate(this)> ... <?php if (some condition) <input name="FR" type="radio" value="" ... ?> So, the function getRadioButtonC hecked is not supposed to be called if FR is not defined, but it does get called and it chokes if the field is not defined.
Isn't there something like "isdefined" or "isset" function in javascript?
Thanks.
Kien wrote: Hi, You can try "undefined"
.... if ((theForm.FR.va lue=="undefined ")) { alert("Please make a selection ....") return false; }
That won't tell you if the field is defined or not, it will tell you if
it's value is "undefined" , a string.
<input type="text" value="undefine d" name="FR"> will pass that test,
even though its "defined".
Which is not what the OP wanted.
Please read the FAQ with regards to top-posting.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/
Thanks a lot, it is working...
For some reason, the code being executed on the server (when I did "view
source") was different than what I was seeing through the FTP terminal
(WS-FTP) or through logging in on the admin page of the web server. It seems
the old page, that did not have the correction in it was being executed,
even though the new page was being showed up through View Source. I have no
idea what was going on. But it is OK now.
Thanks again for your help.
"Janwillem Borleffs" <jw@jwscripts.c om> wrote in message
news:40******** *************** @news.wanadoo.n l... Xerxes wrote: function validate(theFor m){ ... if (theForm.FR) { // FR is the field name, which is a group of radio [...] Isn't there something like "isdefined" or "isset" function in javascript?
Sure, you can use typeof to see if the object doesn't evaluate to 'undefined', but the code in my previous reply has the same result with a shorter notation.
Your problem, however, is that you are not accessing the element through
the elements collection, try:
if (theForm.elemen ts['FR']) { ... }
JW This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Lorenzo Bolognini |
last post by:
Hi all,
why is the DefinedSize of the Field object of type adInteger returning the
value 4 and the same property on a adVarWChar type field (Text in MS Access)
is returning the max length of the string that it may contain (for example
52)?
I'm using ADO 2.8
Thank You,
|
by: ghasem |
last post by:
Dear mySQL community,
I have once again turned to the user groups for a problem I cannot
solve myself! Atually, I have read all I can from the newsgroups on
this but I could not solve it myself.
Here it is:
mySQL server: version "4.0.20-standard" on localhost
hardware : 1.8 MHz Pentium 4 with 512 cache and 512 MB 266MHz RAM and
40 MB Matrox+ harddisk
Here is the problem:
|
by: Steve Wylie |
last post by:
I am constructing an HTML questionnaire and one of the questions
requires people to rate some choices from 1 to 5, where 1 is their
favourite and 5 is their least favourite:
Car
Bus
Taxi cab
Train
Airplane
|
by: Rey |
last post by:
Howdy all.
Appreciate your help with several problems I'm having:
I'm trying to determine if the Visit subform (subformVisits) has a new
record or been changed, i.e. dirty. The form that contains the subform is
named Clients.
I have this code in the Add Client btn:
If Forms!Clients.subformVisits!VisitDirty = True Then
MsgBox "Visit subform is dirty!"
|
by: Boulent Mustafa |
last post by:
Using Microsoft Access 2000, I am defining a bunch of fields all with
default values.
The reason for this is that I have 5 text fields, each of which can
have 5 permutations depending on the value entered in the associated
integer field.
I have been able to define the 5 text fields for integers 1 to 4.
However when I try to define the 5 text fields for the 5th integer,
| |
by: wetherbean |
last post by:
Hi group..I am writing a playlist management protocol where I have a
file that holds all the playlists and a file that holds all the
songs....before a playlist is created I need to check to see if the
playlist file is empty so that I can assign an integer value to a
playlist id field if it is the first playlist being written to the
file....can anyone help?? Thanks in advance
wetherbean
|
by: Henri |
last post by:
In java for instance there's a way to use booleans as objects and not as
value types.
I would like to do the same in VB.NET so that I can check if the boolean has
been explicitely defined (is not Nothing).
But Boolean is a Structure in VB.NET (defined to False by default) and not
an Object so I'm afraid there's no way to do what I want without any
workaround.
Can you confirm that there's no object version of Boolean in VB.NET?
Thanks
|
by: WebBuilder451 |
last post by:
the following simple check for a null valuse is throwing an error
If IsDBNull(Me.DsMem1.usr(0).usrCoState) Then
Response.Write(STAt)
End If
DSMem is a dataset and the value is null. I thought this would check for
null, but it throws an error saying DBNull can not be cast to string?
any help to point out the obvious would be appreciated
thnaks
kes
--
|
by: The Frog |
last post by:
Hello everyone,
I am working on an application that can build database objects in MS
Access from text files. I suppose you could call it a backup and
restore type routine.
Accessing the fields, tables, relationships, and indexes is no issue
for me via DAO code. The issue I have is that I am not sure which
properties are actually necessary / available to set from code for each
possible type of field. I have looked fo´r a reference on...
|
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...
|
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,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |