Hi,
I have a query that displays each row in a table. Each row is a form and I want to validate with JavaScript each form. How can I dynamically create functions ? Here's my code that does not work..
Thanks
Gilles -
<script type="text/javascript">
-
<!--
-
function noEntry2(form_name) {
-
PER_DEB_01 = document.form_name.PER_DEB_01.value;
-
PER_DEB_02 = document.form_name.PER_DEB_02.value;
-
PER_DEB_03 = document.form_name.PER_DEB_03.value;
-
-
var PER_DEB = new Date(2008, 01, 01);
-
var PER_DEB2 = new Date(document.form_name.PER_DEB_01.value, document.form_name.PER_DEB_02.value, document.form_name.PER_DEB_03.value);
-
-
-
if ( (PER_DEB_01.length < 4) || (PER_DEB_02.length < 2) || (PER_DEB_03.length < 2) ) {
-
alert("bla bla bla");
-
document.form_name.PER_DEB_01.focus();
-
return false;
-
}
-
else if (PER_DEB2 < PER_DEB) {
-
alert("bla bla bla");
-
return false;
-
}
-
-
}
-
-
function interval1(form_name) {
-
var DT_DEB_02 = eval('document.'+form_name+'.PER_DEB_02.value');
-
-
if (DT_DEB_02 < 1 || DT_DEB_02 > 12) {
-
alert("bla bla bla");
-
document.form_name.PER_DEB_02.value = ""; // NOT WORKING
-
return false;
-
}
-
else {
-
return true;
-
}
-
}
-
-
function interval2(form_name) {
-
var DT_DEB_02 = eval('document.'+form_name+'.PER_DEB_03.value');
-
-
if (DT_DEB_03 < 1 || DT_DEB_03 > 12) {
-
alert("bla bla bla");
-
document.form_name.PER_DEB_03.value = ""; // NOT WORKING
-
return false;
-
}
-
else {
-
return true;
-
}
-
}
-
-
//-->
-
</script>
-
-
-
-
-
<table width="98%" align="center" border="0" cellpadding="2" cellspacing="0">
-
-
<?php
-
$ctr = 1;
-
while ($recz3 = oci_fetch_array($z3)) {
-
echo "
-
<tr>
-
<form action='save.php' name='form".$ctr."' method='post' onSubmit='return noEntry2(form_name);'>
-
<td>".$recz3["MEDIA"]."</td>
-
<td>
-
<table border='0' cellspacing='0' cellpadding='0'>
-
<tr>
-
<td><input name='PER_DEB_01' value=".substr($recz3["PER_DEB"], 0, 4)." type='text' class='idDate' onKeyUp='return autoTab(this, 4, event);' size='4' maxlength='4' style='width: 40px;'></td>
-
<td>-</td>
-
<td><input name='PER_DEB_02' value=".substr($recz3["PER_DEB"], 5, 2)." type='text' class='idDate' onKeyUp='return autoTab(this, 2, event);' size='2' maxlength='2' style='width: 30px;'></td>
-
<td>-</td>
-
<td><input name='PER_DEB_03' value=".substr($recz3["PER_DEB"], 8, 2)." type='text' class='idDate' onKeyUp='return autoTab(this, 2, event);' size='2' maxlength='2' style='width: 30px;'></td>
-
</tr>
-
</table>
-
</td>
-
<td align='center'><input name='submit' type='image' value='save' src='images/icone_save_v4.gif'></td>
-
</form>
-
</tr>
-
";
-
$ctr++;
-
}
-
?>
-
</table>
-
1 1778
First step is: - document.forms[form_name]..
which will use the form name passed to the function rather than the literal "form_name" which most likely does not exist.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mr_burns |
last post by:
hi,
is it possible to change the contents of a combo box when the contents
of another are changed. for example, if i had a combo box called
garments containing shirts, trousers and hats, when...
|
by: brian.newman |
last post by:
I'm trying to use a layer inside a form to hide/reveal a part of the
form, but my code doesn't seem to be working and I need some help
debugging it.
I'm not getting an error which has made it...
|
by: iam247 |
last post by:
Hi
I have an ASP form which only includes an option list. The list is
dynamically created but includes a default value, which is an
instruction "Select a group".
The code is shown at bottom....
|
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: Nathan Sokalski |
last post by:
When testing a form of mine which uses RequiredFieldValidators that have the
Display property set to "Dynamic" the ErrorMessage property is automatically
removed when an entry is completely typed...
|
by: kusanagihk |
last post by:
To all,
I'm working on a javascript to dynamic build a common set of HTML
controls.
01) I've used the DOM object to build a <div> tag; then build 1 <input
type='button'/> and 1 <input...
|
by: jedimasta |
last post by:
Good evening all,
I'm a relatively new to javascript, but I've been working with
ColdFusion and PHP for years so I'm not necessarily ignorant, just
stuck and frustrated. Using ColdFusion I'm...
|
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: matt |
last post by:
hello,
i am on an interesting project. in this project, i have to create
dynamic data-entry forms for offline-users to fill out, save locally,
and eventually postback to our app (when back...
|
by: Steve Funk |
last post by:
All, I have searched all around and have not yet found the answer to this nor
a solution. Hopfully it will be easy to overcome.
Here is what I am trying to do:
I'm trying to build a wizard...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |