473,657 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2752
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.fo rm)".

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.c om...
"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.fo rm)".

Jul 20 '05 #3

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

Similar topics

9
4950
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 webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
4
6857
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 following code, everything work perfctly: <Input type=button VALUE="Submit your form" onClick="javascript:return CheckIt(TheForm)">
2
1224
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 screen for three users who have individual pre-assigned passwords so i need some logic testing as per below // ========START OF CODE=========
8
2006
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 to that button, so there is no text to be selected. What should I do? Below you'll see some code that I have in one of my forms. I was hoping to have these buttons and when I click on them they would take selected text from a textarea box and...
8
1674
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 miles the person enters "myitem" is the row...there are seven rows where they can list expenses. "myvalue" * .375 = amount to be reimbursed All the rows are added and placed into the total.
2
2130
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. Till now. This is the problem (and the page):
2
10918
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 the functions are that you can fill in the fields and when you press on a button you go to a new page, were all filled fields are shown. Now i want to validate the form before i pass on the filled information to the "next page". But right now...
8
1933
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) { if (strpos($Address, '@') !== FALSE && strpos($Address, '.') !== FALSE) { return true; } else if (validateSender($_GET) == false) {
13
7800
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 statement used in calling the function validateForm rather than being included inside the function? Thanks in advance,
0
8420
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
8324
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
8842
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
8740
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 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...
1
8516
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,...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
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...
1
2743
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
2
1733
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.