473,396 Members | 1,767 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,396 software developers and data experts.

trouble calling a function to validate form input

i'm trying to pass a form object to a function to validate the forms user
input
when i try to access a forms properties-like .elements[x] there is no
response from the function and no error msg, i get a screen flash
and
if i try to preset an element property before calling the function like:
this.firstName.optional=true;
the code after that doesn't get executed
going bananas, please help

to successfully call the function:
<input type="button" value="Submit Volunteer Information"
onclick="
alert('this message at start of onclick');
verify(this);">

the called function:
function verify(f) {
alert('now entering verify function');
var msg1 = "the current message is = " ;
var e = f.elements[0];
msg1 += e.type;
alert(msg1);
return false;
}
so...... i get the first alert, then nothing????

and while on the subject this code does not even get as far as the 2nd
alert:
<input type="button" value="Submit Volunteer Information"
onclick="
alert('this message at start of onclick');
this.firstName.optional=true;
alert('this message after optional assignment');
verify(this);">
Jul 20 '05 #1
2 2743
Lee
"bbxrider" said:

i'm trying to pass a form object
... <input type="button" value="Submit Volunteer Information"
onclick="
alert('this message at start of onclick');
this.firstName.optional=true;
alert('this message after optional assignment');
verify(this);">


In the context of an onClick handler, "this" refers to the
form element, not the form. Since each element has an
attribute named "form", which is a reference to its parent
form, you want to use: "verify(this.form)".

Jul 20 '05 #2
thanks for the help, that works, and found as well, to set an attribute of a
field, like .optional
that needs this.form as well.
i've searched high and low to find lists of properties and methods for .form
and nothing is showing up
in google groups, any suggestions where to find that documentation? and not
just for .form but all the
objects in html objects

"Lee" <RE**************@cox.net> wrote in message
news:bg*********@drn.newsguy.com...
"bbxrider" said:

i'm trying to pass a form object
...

<input type="button" value="Submit Volunteer Information"
onclick="
alert('this message at start of onclick');
this.firstName.optional=true;
alert('this message after optional assignment');
verify(this);">


In the context of an onClick handler, "this" refers to the
form element, not the form. Since each element has an
attribute named "form", which is a reference to its parent
form, you want to use: "verify(this.form)".

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
4
by: evan.cooch | last post by:
Greetings. Suppose I have some function called "CheckIt" - some function to validate form data before submitting it to e CGI script. Pretend the name of the form is "TheForm". If I use the...
2
by: DSL | last post by:
I'm pulling my little hair that's left out trying to figure out how I can call a function from within a function. Here's the deal... and yes I know I should be using PHP! I have a password login...
8
by: lawrence | last post by:
I'm a beginner with Javascript and especially cross-browser Javascript. I got this working in IE, but not in Netscape 7. It seems like, in Netscape, every time I click on a button, the focus shifts...
8
by: Abby Lee | last post by:
My function works but there has got to be a way to make a for loop to handle this...but I can't get a for loop to work. You can tell, I'm not very good at this...help. "myvalue" is the number of...
2
by: Fabri | last post by:
I would like to ask you the following: I use Macromedia Dreamweaver as an editor for HTML and Js. It also writes some js functions to simply validate forms. I always used it with no bugs. ...
2
by: cryme | last post by:
Im having a minor, simple problem. Basicly i have two different scripts they both work separately and together but just that both executes at the same time. On my html page i have a form, one of...
8
by: cutlass | last post by:
Need you assistance to anyone who is willing to offer. I have been working on this script and can't get it to work. The issue I'm having is the statement: function validateSender($Address)...
13
by: Steve | last post by:
On page 392 of "Javascript the definitive guide" a function is called like this:- <form action="processform.cgi" onsubmit="return validateForm();"> Why, in this instance, is the return...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
jinu1996
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...
0
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...
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.