I am a newbie to this and am having a problem with validation and keeping data that has been entered in other fields when submitting the form.
For the check boxes, I need a minimum of one selected. If one is not selected, a message box appears notifying that a check box has not been selected. When I click OK, the data in the other text boxes is removed as if the form is being reloaded. How can I prevent this from happening.
Is there a better way to validate the checkboxes. I have searched and most instances of validation refer to linking to an outside validation jsp. This can not be done for this situation. Any help would be most appreciated.
[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="javascript">
function validate(){
var A = document.forms[0].elements['OBKey_Generic_Field_01_1'];
var B = document.forms[0].elements['OBKey_Generic_Field_02_1'];
var C = document.forms[0].elements['OBKey_Generic_Field_03_1'];
var D = document.forms[0].elements['OBKey_Generic_Field_05_1'];
if (A.checked == 1){
alert("Are you sure you want to submit form?");
return false;
}
if (B.checked == 1){
alert("Are you sure you want to submit form?");
return false;
}
if (C.checked == 1){
alert("Are you sure you want to submit form?");
return false;
}
if (D.checked == 1){
alert("Are you sure you want to submit form?");
return false;
}
else
alert("You must select type of additional documentation submitted")
}
</script>
</head>
<form action="" method="post" name="ACH" onSubmit="return validate();" >
<body>
<table width="905" border="0" cellpadding="1" cellspacing="1" class="h1">
<tr>
<td width="145" class="text" height="28"><div align="right">
<div align="right">Bank Name: </div>
</div></td>
<td width="314" height="28"><input class="text" name="OBKey__206_1" size="50" tabindex="6"></td>
<td width="214" class="text" height="28"><div align="left"> ABA # (must be 9 digits: </div></td>
<td width="219" height="28" ><div align="left">
<input name="OBKey__60_1" type="text" size="9" maxlength="9" tabindex="7" >
</div></td>
</tr>
</table>
<tr>
<td ><hr></td>
</tr>
<table width="901" border="0" cellpadding="1" cellspacing="1" class="h1">
<tr>
<td width="250" height="22" class="h2A">VI. Additional documentation submitted:</td>
<td width="644" height="22" colspan="2" class="text"><input name="OBKey_Generic_Field_01_1" value="ON" type="checkbox" tabindex="10">
Direct Allocated (Screen Prints)</td>
</tr>
<tr>
<td width="250" height="26" class="text"></td>
<td height="26" class="text" colspan="2"><input name="OBKey_Generic_Field_02_1" value="ON"type="checkbox" tabindex="11">
Canceled Check Request </td>
</tr>
<tr> </tr>
<tr>
<td width="250" height="26" class="text"><div align="left" class="h2A">
<td height="26" class="text" colspan="2" valign=""><input name="OBKey_Generic_Field_03_1" value="ON" type="checkbox" tabindex="12">
Stop Payment Request</td>
</tr>
<tr>
<td width="250" height="35" class="text"><div align="left" class="h2A">
<td height="35" class="text" colspan="2" valign=""><input name="OBKey_Generic_Field_05_1" value="ON" type="checkbox" tabindex="13">
Other</td>
</tr>
<tr>
<td width="250" height="32" class="text" valign="baseline"><div align="left" class="h2A">
<td align="left" valign="top" ><input type="submit" value=Submit name="OBBtn_Save" tabindex="14" >
<input type="submit" value="Cancel" name="OBBtn_No" >
</td>
</tr>
</table>
</body>
</html>[/HTML]