Board Logo

Check for checkbox
sunjournal - 8/19/2004 at 02:08 PM

Great script. I'm wondering how to check for radio buttons and checkboxes in a form to make sure a user has selected one?

opacons - 12/24/2004 at 12:43 AM

Me too

tigra - 2/17/2005 at 07:48 PM

fix introduced in v1.2

zip_puff - 5/4/2005 at 02:12 AM

This is a wonderful script: clean, professional, deploys easy. But I haven't been able to discern the fix for check boxes / radio buttons. Where can I find the documentation please?

zip_puff - 5/4/2005 at 05:10 AM

This is the code from validator.js.

else if (o_input.length > 0) // radiobuton
for (var n_index = 0; n_index < o_input.length; _index++)
if (o_input[n_index].checked) {
s_value = o_input[n_index].value; break;

But I saw nothing collateral in the form fields description structure, so I created:

'radiobutton':{'l':'Advertiser or Visitor','r':true,'f':'radiobutton','t':'t_radiobutton',},

The HTML is:

<td align="left" valign="middle" id="t_radiobutton">&nbsp;</td>
<td colspan="2">Advertiser<input type="radio" name="radiobutton" value="radiobutton"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Visitor&nbsp;
<input type="radio" name="radiobutton" value="radiobutton"></td>

What am I missing?

katAttack - 6/3/2005 at 12:51 AM

I have checkboxes working, both as <b>isolated</b> one off elements and as <b>collective groups</b>.

my collective example:


<p><input type="checkbox" name="fObtainedKnowledge" value="Supervision" id="fHowSupervision">&nbsp;&nbsp;<label for="fHowSupervision">Supervision</label></p>
<p><input type="checkbox" name="fObtainedKnowledge" value="Other%20Training" id="fHowTraining">&nbsp;&nbsp;<label for="fHowTraining">Other&nbsp;training</label></p>
<p><input type="checkbox" name="fObtainedKnowledge" value="Reading" id="fHowRead">&nbsp;&nbsp;<label for="fHowRead">Reading</label></p>
<p><input type="checkbox" name="fObtainedKnowledge" value="Practical%20Experience" id="fHowPractical">nbsp;&nbsp;<label for="fHowPractical">Practical&nbsp;experience</label></p>

In the example above I want them to make at LEAST one checkbox choice. The group is collectively named <b>"fObtainedKnowledge"</b> so I get a single array of values posted by the form.

In line with HTML 4 and accessibility each element in the collective group have a unique ID e.g fHowPractical, fHowRead, fHowTraining .....

The <b>Tiagra definition entry for this field group</b> is:

'fObtainedKnowledge':{'l':'Where you obtained the knowledge','r':true,'t':'labelIDtoHighlight'},

This forces at least one checkbox to be ticked and if none are ticked the HTML element named ID="labelIDtoHighlight" will be flagged to the user...

There is an obvious issue here if you desire to highlight/flag all elements within the collective group as the code only supports the identification of a single element ID for the 'flag' function.

I have a solution though, I wrote new code to support the passing of an array of ID names for the 'l': "labelID" function.

gtennant - 1/16/2006 at 02:50 PM

I'm not a programmer, but I can find my way around HTML and Flash quite well. I need to check a form to ensure that a set of 5 checkboxes have been selected, before the form gets submitted, and the viewer is taken to a "congratulations" page. Care to share your "code" on how that might be done?

Appreciated immensely, in advance.

Here's my form code:

<form action="" method="post" enctype="application/x-www-form-urlencoded" name="Survey" class="style9" id="Survey">
<p>Take our (required) short survey... </p>
<p class="text">
<input name="income" type="checkbox" id="income" value="income yes">
<span class="style10">Can you prove (verify) your income?</span></p>
<p class="text">
<input name="residence" type="checkbox" id="residence" value="residence yes">
<span class="style10">Can you prove (verify) your residence?</span></p>
<p class="text">
<input name="drivers_licence" type="checkbox" id="drivers_licence" value="driver's licence">
Do you have a valid driver's license?</p>
<p class="text">
<input name="insurable" type="checkbox" id="insurable" value="insurable yes">
Are you insurable?</p>
<p class="text">
<input name="downpayment" type="checkbox" id="downpayment" value="downpayment yes">
Do you have a minimum of $299 (+tax=$344) for a down payment?</p>
<p class="text">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset">

davidwwatts - 1/14/2007 at 03:51 PM

I've managed to implement katattack's code, however the resulting parameters passed to the CGI script on the form don't appear to work. The problem is that if two checkboxes are checked, then two variables of the same name are passed.

Using katattach's example, if Supervision and Reading were checked, then the parameters passed will be


So how is the CGI supposed to be able to process that properly? All I get when I look at that variable is the value "Reading".

Anyone successfuly implemented checkbox validation? Unfortunately, it's not in the documentation?

davidwwatts - 1/16/2007 at 01:30 PM

Ok answering my own question. The answer is it depends on the language used. I'm using Perl, so the syntax is:

my @fObtainedKnowledge = $query->param("fObtainedKnowledge");

Then I can address each of them as $fObtainedKnowledge[0] for the first one or $fObtainedKnowledge[1] for the 2nd one and so on.


Hollstar - 4/11/2008 at 12:32 PM

Depending on how you're using the checkboxes in question, it should be like checking any other form element.

In my example, I have an array of checkboxes thus the code is as follows:
'chkCheckboxArray[]':{'l':'Error Title','r':true,'t':'t_txtCheckboxID'}

gtennant - 4/11/2008 at 12:43 PM

Look at the date of the last message.

This thread is dead, it's 5 years old...


ScriptKid - 5/5/2008 at 03:01 PM

As far as I know checkboxes are not supported in the latest version of Tigra Form Validator.

There is nothing in the documentation about setting it up.

Anyone have an example? I'll create a new thread if I need to...

ScriptKid - 5/12/2008 at 08:27 PM

I got it working with version 1.3.

The registered version that I have of Tigra Validator PRO is 1.1. The checkbox issue was fixed in version 1.2.

Unfortunately this means I must use either the Validator PRO 1.1 or the FREE Validator 1.3.

How do I get an upgraded version of PRO 1.3? I cannot find my registration information (it's been a couple years... perhaps we have to renew?) It's been 72 hours since I submitted this to customer service with no resolution. I heard back from customer service and confirmed that I cannot locate the registration # for 1.1.

At this time I do have checkboxes working, but I need to add custom locale Alert Confirmation messages that is only provided in the PRO editions.

tigra - 5/12/2008 at 09:20 PM

The product comes with free upgrades during at least one year since the date of your purchase.
Usually we provide non-major version upgrades free of charge even after that free term expires.
To get the new version please submit a support ticket providing your order ID.

Back to forum: