Board Logo

Radio Buttons invalidating Validation code
desWork - 7/25/2005 at 04:24 PM

Hi there
I have incorporated the Tigra Validation code into a form I am hosting on a website. I'm having trouble with the radio buttons included in my form and validation script. If I select a radio option but don't fill in any of the other required fields it is still possible to submit the form. Obviously I want all my required fields to be filled in before the user can post it.

HTML Code:

<td valign="top" id="t_requirements">
Requirements*
</td>
<td valign="top">
<table width="350">
<tr>
<td valign="top"><label>
<input type="radio" name="RadioGroup1" value="Specifications Only">
Specifications only</label>
</td>
</tr>
<tr>
<td valign="top"><label>
<input type="radio" name="RadioGroup1" value="Specifications And Sample">
Specifications &amp; sample</label>
</td>
</tr>
<tr>
<td valign="top"><label>
<input type="radio" name="RadioGroup1" value="Other">
Other <span class="greyText">(please specify in 'Other Requirements' box)</span></label><br /><br />
</td>
</tr>
</table> </p>
</td>


JavaScript in the body tags:

'RadioGroup1' : {'l':'Requirements','r':true,'f':'radiobutton','t':'t_requirements'},


VBScript in the ASP file:

& "REQUIREMENTS: " & Request.Form("RadioGroup1") &


This is a real head scratcher for me so your thoughts would be warmly received.


lamojo - 3/13/2008 at 12:26 PM

hi! i solved this with javascript and an extra hidden field

in the example above i would add:

<input type="hidden" id="RadioGroup1Selected" name="RadioGroup1Selected" value="">

and add javascript to the radio buttons:

<input type="radio" name="RadioGroup1" value="Specifications And Sample" onchange="document.getElementById('RadioGroup1Selected').value='true';" >


and then require the field 'RadioGroup1Selected' in the validation


a little late for desWork, but other developers might accidentally stumble upon this solution thru this primitive search engine called Google :)


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/