473,769 Members | 2,348 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check box validaton

17 New Member
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>Untitl ed Document</title>
<script language="javas cript">
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="retur n validate();" >
<body>
<table width="905" border="0" cellpadding="1" cellspacing="1" class="h1">
<tr>
<td width="145" class="text" height="28"><di v align="right">
<div align="right">B ank Name:&nbsp;</div>
</div></td>
<td width="314" height="28"><in put class="text" name="OBKey__20 6_1" size="50" tabindex="6"></td>
<td width="214" class="text" height="28"><di v align="left">&n bsp;&nbsp;&nbsp ; ABA # (must be 9 digits:&nbsp; </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"><i nput name="OBKey_Gen eric_Field_01_1 " value="ON" type="checkbox" tabindex="10">
&nbsp;Direct Allocated (Screen Prints)</td>
</tr>
<tr>
<td width="250" height="26" class="text"></td>
<td height="26" class="text" colspan="2"><in put name="OBKey_Gen eric_Field_02_1 " value="ON"type= "checkbox" tabindex="11">
&nbsp;Cancel ed Check Request </td>
</tr>
<tr> </tr>
<tr>
<td width="250" height="26" class="text"><d iv align="left" class="h2A">
<td height="26" class="text" colspan="2" valign=""><inpu t name="OBKey_Gen eric_Field_03_1 " value="ON" type="checkbox" tabindex="12">
&nbsp;Stop Payment Request</td>
</tr>
<tr>
<td width="250" height="35" class="text"><d iv align="left" class="h2A">
<td height="35" class="text" colspan="2" valign=""><inpu t name="OBKey_Gen eric_Field_05_1 " value="ON" type="checkbox" tabindex="13">
&nbsp;Other</td>
</tr>
<tr>
<td width="250" height="32" class="text" valign="baselin e"><div align="left" class="h2A">
<td align="left" valign="top" ><input type="submit" value=Submit name="OBBtn_Sav e" tabindex="14" >
<input type="submit" value="Cancel" name="OBBtn_No" >
</td>
</tr>
</table>




</body>
</html>[/HTML]
Jun 17 '08 #1
1 1532
acoder
16,027 Recognized Expert Moderator MVP
Your validation is wrong way round. If one is checked, return true, not false. Also, the way to validate would be check if none of them are checked. If so, return false. At the end of the validation function, return true.

Since the checkboxes are connected, use the same name, so you can get them at once with document.getEle mentsByName().
Jun 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

17
4179
by: Craig Bailey | last post by:
Someone please explain what alternate universe I fell into this afternoon when PHP started telling me that 2 doesn't equal 2. Not sure about you, but when I run this, it tells me 59001.31 doesn't equal 59001.31. Change each side of the equation by a hundreth or two and it checks. Change it a bit more, and it won't. _What_ is going on here?! <?php
7
29933
by: Tony Johnson | last post by:
Can you make a check box very big? It seems like when you drag it bigger the little check is still the same size. Thank you, *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
2
27813
by: Travis.Box | last post by:
I have an MS Access userform with 16 Check Boxes. Each of the checkboxes has a different option value, which coincides with the Check Box name (eg. cb01.OptionValue = 1). At the bottom of the form is a command button. When the command button is clicked, I need the VBA scripting to determine which Check Box has been selected, and then assign a vaule to a string based on which Check Box has been selected. What I'm having trouble figuring...
9
3386
by: simonmarkjones | last post by:
I want to call a function which does this when the next record button is pressed (calling it from before update) if textboxes are empty then Message box you must fill text box
1
4265
by: scprosportsman | last post by:
Please help guys, i am trying to set up a database here at work and im fairly new to access in terms of writing functions and queries and stuff. I have 2 different places on my design that will require checking a check box to tell which category something will pertain to. Well after each record is entered i want the check to remain with that record and auto clear when going to the next record so i can input something else if i have a...
2
3598
by: Chris Davoli | last post by:
How do you enable a check box in the GridView. I selected Checkbox Field in the Columns of the GridView, and the check box shows up in the Grid view, but it is disabled. How do I enable it so I can check/uncheck it. Also, what event do I use to check it for a value? Any articles out there? -- Chris Davoli
16
5665
by: Brian Tkatch | last post by:
Is there a way to check the order in which SET INTEGRITY needs to be applied? This would be for a script with a dynamic list of TABLEs. B.
5
11653
by: starke1120 | last post by:
Im creating a check in – check out database for RF guns. I have a table that contains models. ID (primary key) Model A table that contains Gun Details ID (primary key) Model_id Gun_Number (assigned gun number by operations)
1
2414
by: ghjk | last post by:
my php page has 7 check boxes. I stored checked values to database and retrive as binary values. This is the result array Array ( => 0 => 1 => 0 => 1 => 0 => 0 => 1 ) 1 means checked. I want to display these results in check boxes. This is my code. But it doesn't work <tr><td><input value="1" type="checkbox" id="1" name="check" <?php if ($array==1) echo "value=checked";?>/>Fasting 6 hours</td> <td><input value="2"...
0
9586
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
9423
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
10210
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
8869
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
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
6672
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
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...
0
5446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3956
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

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.