Can someone look at this code and tell me what is wrong? The error
message says "Line 8 Char 1 'dealerId' is undefined" But I thought that
I stated everything correctly. Do I have any syntax errors in here. The
code is supposed to display an alert if someone typed in letters
instead of numbers for each input box.
---------------------------------------------------------------------------------------------------------------------------------------
<script>
function validateInputs() {
var validInputs=(IsValidNumber(dealerId,DealerID)
&&IsValidNumber(seriesId,SeriesID)
&&IsValidNumber(modelId,ModelID)
&&IsValidNumber(extColorId,ExteriorColorID)
&&IsValidNumber(fabricTypeId,FabricTypeID));
if(!validInputs){
return false;
}
}
function IsValidNumber() {
var input = document.getElementById(inputId);
if(!validateNumber(input,inputDescription)){
return false;
}else{
return true;
}
}
var re = /^\d+$/;
function validateNumber(input, inputName) {
var validNumber = re.exec(input.value);
if (!validNumber) {
alert("Input a valid number in " + inputName + " now!");
input.focus();
return false
} else {
return true;
}
}
</script>
html:
<form id="Form1" action="DisplayMultipleProcedures.aspx" method="post"
onsubmit="return validateInputs();">
---------------------------------------------------------------------------------------------------------------------------------------
Thanks :) 4 1540
Jessica wrote: Can someone look at this code and tell me what is wrong? The error message says "Line 8 Char 1 'dealerId' is undefined" But I thought that I stated everything correctly. Do I have any syntax errors in here. The code is supposed to display an alert if someone typed in letters instead of numbers for each input box. ---------------------------------------------------------------------------------------------------------------------------------------
<script> function validateInputs() { var validInputs=(IsValidNumber(dealerId,DealerID) &&IsValidNumber(seriesId,SeriesID) &&IsValidNumber(modelId,ModelID) &&IsValidNumber(extColorId,ExteriorColorID) &&IsValidNumber(fabricTypeId,FabricTypeID)); if(!validInputs){ return false; } } function IsValidNumber() { var input = document.getElementById(inputId); if(!validateNumber(input,inputDescription)){ return false; }else{ return true; } }
var re = /^\d+$/; function validateNumber(input, inputName) { var validNumber = re.exec(input.value);
if (!validNumber) { alert("Input a valid number in " + inputName + " now!"); input.focus(); return false } else { return true; } } </script>
html: <form id="Form1" action="DisplayMultipleProcedures.aspx" method="post" onsubmit="return validateInputs();">
Thanks :)
You have forgot to declare the parameters in "function IsValidNumber()":
function IsValidNumber(inputId, inputDescription) { ...
Also, the way you use those params, you have to give them as strings
when you call "IsValidNumber(...)", like this:
function validateInputs() {
var validInputs=(IsValidNumber('dealerId', 'DealerID')
&& IsValidNumber('seriesId', 'SeriesID')
&& IsValidNumber('modelId', 'ModelID')
&& IsValidNumber('extColorId', 'ExteriorColorID')
&& IsValidNumber('fabricTypeId', 'FabricTypeID'));
return validInputs;
}
--
Dag.
Jessica wrote: Can someone look at this code and tell me what is wrong? The error message says "Line 8 Char 1 'dealerId' is undefined" But I thought that I stated everything correctly.
<script> function validateInputs() { var validInputs=(IsValidNumber(dealerId,DealerID)
Nothing in your code defines what "dealerId" is. You didn't state it at all.
(Hint: Giving a form element a name in HTML does not create a variable in
the global JavaScript namespace with the same name that is a referenc etot
hat element. http://www.mozilla.org/docs/web-deve...ade_2.html#dom )
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jessica wrote: Can someone look at this code and tell me what is wrong?
Your post does not include the HTML with which this code is attempting
to interact so suggesting how it might be made to function will be
impractical.
The error message says "Line 8 Char 1 'dealerId' is undefined"
'dealerId' is not defined. Indeed, there appear to be a score of
Identifiers used in this script that have never been declared, or
assigned values. The error given just marks the first runtime error
caused by accessing an undeclared variable.
But I thought that I stated everything correctly.
What do you mean by that?
Do I have any syntax errors in here.
Syntax errors would be reported before any code was executed, so the
fact that you are getting a runtime error indicates no syntax errors.
The code is supposed to display an alert if someone typed in letters instead of numbers for each input box.
<snip>
See:-
<URL: http://www.jibbering.com/faq/faq_notes/form_access.html >
Richard.
Jessica said: Can someone look at this code and tell me what is wrong? The error message says "Line 8 Char 1 'dealerId' is undefined" But I thought that I stated everything correctly. Do I have any syntax errors in here. The code is supposed to display an alert if someone typed in letters instead of numbers for each input box. ---------------------------------------------------------------------------------------------------------------------------------------
<script> function validateInputs() { var validInputs=(IsValidNumber(dealerId,DealerID)
^^^^^^^^
"DealerID" needs to be in inverted commas - it's a string not a variable.
&&IsValidNumber(seriesId,SeriesID) &&IsValidNumber(modelId,ModelID) &&IsValidNumber(extColorId,ExteriorColorID) &&IsValidNumber(fabricTypeId,FabricTypeID)); if(!validInputs){ return false;
^^^^^^^^^^^^^
you don't need this - you can just do 'return validInputs' } } function IsValidNumber() {
^^
You haven't defined any parameters for this function.
var input = document.getElementById(inputId); if(!validateNumber(input,inputDescription)){ return false; }else{ return true; }
you don't need this function - just do validateNumber(dealerId,"DealerID")
} } var re = /^\d+$/; function validateNumber(input, inputName) { var validNumber = re.exec(input.value);
if (!validNumber) { alert("Input a valid number in " + inputName + " now!"); input.focus(); return false } else { return true; } }
This bit looks OK.
</script>
html: <form id="Form1" action="DisplayMultipleProcedures.aspx" method="post" onsubmit="return validateInputs();"> ---------------------------------------------------------------------------------------------------------------------------------------
Thanks :)
-- http://www.niftybits.ukfsn.org/
remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: TG |
last post by:
I have a validation form that must behave differently based on the results
of a PHP validation check. I have a post command at the top of my form that
calls itself. I don't leave the form when...
|
by: What-a-Tool |
last post by:
I have a school project (ASP) in which I have to call three different ASP
pages from three different and identical (except for the form "action",
obviously) HTM pages. This I have no problem with....
|
by: brian_mckracken |
last post by:
This might not be the right group for this question, since its kind of
a pure html question...
Given the html construct:
<form action='index.php?expand=0,10000' method='post'>
Email: <input...
|
by: Hosh |
last post by:
I have a form on a webpage and want to use JavaScript validation for the
form fields.
I have searched the web for form validation scripts and have come up with
scripts that only validate...
|
by: nescio |
last post by:
hello,
i have an array and i don't know the content of it, but i want only unique
values.
in php there is a function to do this, but how must i do this in javascript?
i have tried a lot and...
|
by: julie.siebel |
last post by:
Hello all!
As embarrassing as it is to admit this, I've been designing db driven
websites using javascript and vbscript for about 6-7 years now, and I
am *horrible* at form validation.
To be...
|
by: nescio |
last post by:
hello,
i am making a form using php/html/javascript
a part of the form is (email address) comming from a database.
the amount of addresses is always different.
every address has a checkbox....
|
by: Chris |
last post by:
Hi,
I have a form for uploading documents and inserting the data into a mysql
db. I would like to validate the form. I have tried a couple of Javascript
form validation functions, but it...
|
by: Rik |
last post by:
Hello guys,
now that I'm that I'm working on my first major 'open' forms (with
uncontrolled users I mean, not a secure backend-interface), I'd like to add
a lot of possibilities to check wether...
|
by: =?Utf-8?B?SGFyZHkgV2FuZw==?= |
last post by:
Hi all,
I followed first walk through sample from
http://ajax.asp.net/docs/tutorials/IntroductionUpdatePanel.aspx to create my
first testing page, The problem is after I clicked that botton, it...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
|
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...
|
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: 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,...
|
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...
| |