This is probably a no brainer, but I am having no luck at getting this to
work. I'm creating functions that will validate form data fields. For
example, the following function:
function checkText(field, msg, min, max) {
if (!min) { min = 1 }
if (!max) { max = 65535 }
if (!field.value || field.value.length < min || field.value.max > max ||
!field.value.match(/^[a-zA-Z]*$/)) {
alert(msg);
field.focus();
field.select();
return false;
}return true;
}
I tested the above function and it works great. The problem is I have
several different functions that will check for fields with different data
like: numbers only, selections in drop down menus, valid zip code, etc. I'm
trying to create one function that I can call using the onSubmit event that
will go through each function to validate all the fields in the form.
I was trying to use the following function to accomplish this using just the
first function. I would include other if statements for the other
functions.
function formValidation(thisform) {
if (checkText(this.first_name, 'Please enter your first name.', 2,
15)==false) {
return true;
}
return false;
}
then within the form tag, I called the function: onSubmit="return
formValidation(thisform)
I'm not all that proficient with Javascript as I'm still learning. Can
anyone identify my mistake in the formValidation function? The argument
"thisform" doesn't need to be the name of the HTML form does it? I thought
it could be any name of my choosing? Any help is greatly appreciated.
Thanks in advance.
-D- 1 1935
Dwayne said: function formValidation(thisform) { if (checkText(this.first_name, 'Please enter your first name.', 2, 15)==false) { return true; } return false; }
then within the form tag, I called the function: onSubmit="return formValidation(thisform)
I'm not all that proficient with Javascript as I'm still learning. Can anyone identify my mistake in the formValidation function? The argument "thisform" doesn't need to be the name of the HTML form does it? I thought it could be any name of my choosing? Any help is greatly appreciated. Thanks in advance.
In the line:
function formValidation(thisform) {
the "formal parameter" can be any name of your choosing,
but you have to use it consistently. In the next line
you refer to "this.first_name". That should be
"thisform.first_name".
In the onSubmit attribute, on the other hand, the "actual
parameter" is not any name of your choosing. In this
particular case, it should be "formValidation(this)",
because the attribute named "this" is a reference to the
form that is being submitted. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kostatus |
last post by:
I have a virtual function in a base class, which is then overwritten by a
function of the same name in a publically derived class. When I call the
function using a pointer to the derived class (ClassB* b; b->func(); ) the
base-class function is called instead of the new function in the derived
class. All other similar functions (virtual in...
|
by: andy |
last post by:
i am coding a dll which contains a function take a const wchar_t* as
parameter, call it form a exe, the wchar_t is passed to dll function,
but the function in dll will then call another function and pass that
wchar_t* parameter to another function, now the problem is that
functions in dll, when exported function pass parameter another...
|
by: Jan-Henrik Grobe |
last post by:
Hallo,
I am coming to this newsgroup with a very strange Problem. I have two c++
files A.cpp and B.cpp....In A.cpp I am creating an openGL window and in
B.cpp I have stored the callback functions. Important is, that the object
A.o has to be created BEFORE B can be compiled. I am sure that sounds
confusing but A.cpp is part of a library that...
|
by: Hennie de Nooijer |
last post by:
Because of an error in google or underlying site i can reply on my own
issue. Therefore i copied the former entered message in this message.
-------------------------------------REPY----------------------------------
Hi Maybe i wasn't clear. I want to dynamically check whether what the
lowest date and the highest date is in the calendar table....
|
by: jimfortune |
last post by:
I have an A97 module called modWorkdayFunctions in:
http://www.oakland.edu/~fortune/WorkdayFunctions.zip
It allows the counting of workdays taking into consideration up to 11
U.S. holidays. More holidays can be added easily. Also, there is a
boolean flag for including or excluding Saturdays or Sundays as part of
the work week. The only...
| |
by: Andy_Khosravi |
last post by:
Hello,
I'm having a problem with the MID function within Access 97. I have
been trying to build a function to check to make sure that a field on a
form does not have any spaces or dashes. This should be easy enough to
do using the MID function in a For...Next statement. However, I've had
more than a few problems.
My first problem was...
|
by: Mike D. |
last post by:
I have a problem with a dynamic library I am developing, but it is
really more of a pointer issue than anything else. Hopefully someone
here can lend me some assistance or insight into resolving this.
Ok... here goes....
I have a function that passes a pointer to a string to another
function. For example:
int FunctionA ()
|
by: Fernando Barsoba |
last post by:
Dear all,
I have been posting about a problem trying to encrypt certain data using
HMAC-SHA1 functions. I posted that my problem was solved, but
unfortunately, I was being overly optimistic. I am really desperate now,
because I havent' been able to locate the origin of the problem for a
couple of days now..
PROBLEM: the message digest...
|
by: Josiah Manson |
last post by:
I found that I was repeating the same couple of lines over and over in
a function and decided to split those lines into a nested function
after copying one too many minor changes all over. The only problem is
that my little helper function doesn't work! It claims that a variable
doesn't exist. If I move the variable declaration, it finds the...
|
by: RandomElle |
last post by:
Hi there
I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with or without parms. I know that any function that is passed to Eval() must be declared Public. It can be a Sub or Function, as long as it's Public. I...
|
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...
| |
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...
|
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. ...
|
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...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |