Radio validation problem

Noterious 12 May, 2008
I searched all over, but still couldn't find what's wrong with my form.

Let's say I have a form like
<p>
  <label>
  <input type="radio" name="fm" value="1" id="radiooo_0" />
    1</label>
  <br />
  <label>
  <input type="radio" name="fm" value="2" id="radiooo_1" />
    2</label>
  <br />
  <label>
  <input type="radio" name="fm" value="3" id="radiooo_2" />
    3</label>
  <br />
</p>


Then I have a built in javascript radio/checkbox to check the field 'fm'

When I click submit, the script returns 'please select one of the above options' on all 3 buttons, not just for the whole group.

I really have no idea what is wrong. Please advice.
GreyHead 13 May, 2008
Hi Noterious,

I'm not clear if you are using ChronoForms validation for this. If you are then you need 'validate one required' with a div around the group of fields.

Bob
Noterious 13 May, 2008
Thanks Bob,

Yes, I'm trying to use ChronoForms validation for the radio buttons.

By using <div> Do you mean something like this?

<div>  
<input type="radio" name="fm" value="1" id="radiooo_0" />  1 <br />  
<input type="radio" name="fm" value="2" id="radiooo_1" />  2 <br />
<input type="radio" name="fm" value="3" id="radiooo_2" />  3 <br /> 
</div>


Or do I have to put in the name="fm" inside the div?
GreyHead 13 May, 2008
Hi Noterious,

Andrew Tetlaw - who wrote the code that ChronoForms uses has this note on the script page:

*To use the validate-one-required validator you must first add the class name to only one checkbox/radio button in the group (last one is probably best) and then place all the input elements within a parent element, for example a div element. That way the library can find all the checkboxes/radio buttons to check and place the validation advice element at the bottom of the parent element to make it appear after the group of checkboxes/radio buttons.

I'm not sure if ChronoForms does this automatically but you can fix it by putting the class="validate_one_required" in your form html; set Validation to ON in he CF tab but *do not* put anything in the Validate One Required box there.

Bob
Noterious 13 May, 2008
Thank you for pointing me to the right direction, Bob.

I finally did it after a few more googling.

<div>
<input type="radio" name="fm" value="1" id="radiooo_0" /> 1 <br /> <input type="radio" name="fm" value="2" id="radiooo_1" /> 2 <br /> <input type="radio" name="fm" value="3" class="validate-one-required" id="radiooo_2" /> 3 <br /> </div>



Worked perfectly! By the way, it's 'validate-one-required', not 'validate_one_required'

*I'm wondering what you use Validate One Required box in CF validation tab for then? It doesn't really work at the moment, since it'll just add 'class="validate-one-required" to every radio buttons with the same name.
Max_admin 13 May, 2008
Good catch, do you have the latest version ? if yes then did you make sure it adds this to all radios ? if yes then its a bug and I will try to find a fix!

another point, what if you added it to the first radio and not the last one, does it work ?

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Noterious 13 May, 2008
I'm using CF V.2.3.9, and yes, it does add 'validate-one-required' class to all radios.

Adding the class to the first radio button works, too.
Max_admin 13 May, 2008
Thanks loads!!

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
hicksticks2001 26 Jun, 2008
Any Idea what I am doing wrong on this?
<p><div>
    <label>
    <input type="radio" name="commission" id="Planning" value="Planning" tabindex="10" />
    Planning</label>
    <label>
    <input type="radio" name="commission"  id="Parks-Recreation" value="Parks-Recreation" tabindex="11" />
    Parks & Recreation</label>
    <label>
    <input type="radio"  name="commission" id="Airport" class="validate-one-required" value="Airport" tabindex="12" />
    Airport</label></div>
  </p>
My form is here

All submissions go to me, so feel free to try it out as much as you want. Thanks for any help or suggestions!
GreyHead 27 Jun, 2008
Hi hicksticks2001,

When you post please say clearly what the problem is. Mind-reading takes too long! In this case I guess that the radio button isn't validating with 'validate-one-required'. There is or was a bug in the validation.js file - the fix is in the forums. You need to add a few lines to the code.

Bob

Later: I've attached the fixed version of mooValidation.js, unzip and replace the existing file in the com_chrnocontact/js folder
cjmicro 18 Aug, 2008
FWIW, I downloaded the new validations js file Bob referenced, installed it and voila' my checkbox validation is now working.

Thanks Bob!!

Cheryl
chakatz 28 Aug, 2008
Hi,
I am using Chronoforms V3.0 BETA 2 with Joomla 1.5.6.
I am not able to get validation working on radio buttons. This is the code I am using:


<p>*Is this your first event?
<div>
<input type="radio" name="CUSTOM5" value="Yes" id="First_Event_0" /> Yes <br />
<input type="radio" name="CUSTOM5" value="No" class="validate-one-required" id="First_Event_1" /> No <br />
</div>
</p>


I have uploaded the new mooValidation.js file from the link above but it does not help either.
I have left the validate-one-required field in the Validation tab empty as advised above, since it did not work either.
Any ideas?

Thanks.
cjmicro 28 Aug, 2008
This is how I have mine set up (it is a checkbox, not radio)

<div>
<p><input type="checkbox" name="terms" value="AGREE">   I have read 
  the <a target="_blank" href="http://www.colvinrunpto.org/content/view/57/76/">terms and conditions</a> and indicate my electronic signature and acceptance of these terms and conditions.</p>
</div>


Note that I read somewhere the fields you want in this verify should be in a separate div... so you might want to try that.

Then I have the new mooValidation.js (which I believe you also have), and in the tab, validation,
Enable Validation=YES
Select Validation Library=mootools
12- Radio/Checkbox=terms (name of the field...not sure if you will need both)

Note I do not have the validate-one-required. I am just using the validation tab and it seems to work.

Hope this helps,

Cheryl
This topic is locked and no more replies can be posted.