Required fields and radiobuttons

Shows some Tutorials

Required fields and radiobuttons

Postby pim2000 on Wed Dec 05, 2007 4:11 pm

I am trying to make a form with radiobuttons. People can make a choise out of 6 buttons. When I make the radiobutton required it do not work, because just one button is selected. Now it says that this field is required because the other five are not filled in.

The radiobutton list is build like this:

<input type="radio" name="Gewenst_voertuig" value="klasseA" checked>
<font face="Arial, Helvetica" size="2">klasse A - Bestelauto</font>

every name is the same and the values are different.

Any suggestion would help me out.

Thank you
pim2000
Fresh Boarder
 
Posts: 4
Joined: Wed Dec 05, 2007 9:04 am

Re:Required fields and radiobuttons

Postby GreyHead on Wed Dec 05, 2007 4:23 pm

Hi pim2000,

There's a note on Anrew Tetlaw's site that says
*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 think this will help.

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3253
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Required fields and radiobuttons

Postby pim2000 on Wed Dec 05, 2007 4:55 pm

I am a bit further now. Thanks for the quick advise, but it still gives problems.
I only gave the last one a name:

name="Gewenst_voertuig"
and put the whole radiolist in a div

but it still goes wrong
Image

Do you have any suggestion?
pim2000
Fresh Boarder
 
Posts: 4
Joined: Wed Dec 05, 2007 9:04 am

Re:Required fields and radiobuttons

Postby GreyHead on Wed Dec 05, 2007 5:08 pm

Hi pim 2000,

I think that says class name, not field name. Please try with class="button_group" or something like that.

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3253
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Required fields and radiobuttons

Postby pim2000 on Wed Dec 05, 2007 5:19 pm

OK,

i've a input type, name and value. When I do understand you they have to be filled in for each item. The class must have a name.

I've made a div with the name ' voertuig'

So when I understand you right. Do I have to fill in voertuig in the field 'validate-one-required'

Because I don't find a class?
pim2000
Fresh Boarder
 
Posts: 4
Joined: Wed Dec 05, 2007 9:04 am

Re:Required fields and radiobuttons

Postby GreyHead on Wed Dec 05, 2007 5:24 pm

Hi pim2000,

Here's a snippet of the demo code from Andrew Tetlaw's site. I don't know exactly how this works with ChronoForms
Code: Select all
<div class="field-label"><label for="field6">Sex</label>:</div>
<div class="field-label">
<input type="radio" name="field6" id="field6-male" value="Male" />Male<br />
<input type="radio" name="field6" id="field6-female" value="Female" class="validate-one-required" />Female
</div>
Bob<br><br>Post edited by: GreyHead, at: 2007/12/05 15:27
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3253
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Required fields and radiobuttons

Postby pim2000 on Wed Dec 05, 2007 7:36 pm

Thank you!
Everything works
You've helped me very well!
pim2000
Fresh Boarder
 
Posts: 4
Joined: Wed Dec 05, 2007 9:04 am

Re:Required fields and radiobuttons

Postby nosins on Fri Apr 25, 2008 11:18 pm

Hi Bob,

I know that this is an old post, so I'm not sure if there's a better method today, but I've been trying to figure out how to validate at-least-one checkbox in a form.

I've tried implementing these suggestions with no luck. Is there a form and JavaScript example that I could look at and from which I could learn how to do this correctly?

Thanks in advance,

Nick.
nosins
Fresh Boarder
 
Posts: 14
Joined: Sun Apr 20, 2008 1:42 am

Re:Required fields and radiobuttons

Postby admin on Tue Apr 29, 2008 5:17 am

hi, post this part of your form code here and I will try it, whats your Chronoforms version used ?
ChronoForms/ChronoConnectivity/ChronoComments Developer Thanks for using our components!
If you have any problems with any extension please tell us.
If you like any of our extensions please post a review at Joomla.org
Want users to submit their content to your website ? try Submit Story
Want to list/edit/delete your data ? try ChronoConnectivity
Want to have stylish AJAX comments ? try ChronoComments
User avatar
admin
Platinum Boarder
 
Posts: 2330
Joined: Mon Aug 14, 2006 5:29 am

Re:Required fields and radiobuttons

Postby nosins on Tue Apr 29, 2008 5:21 am

Thanks for looking into this Bob. Here's the code:
Code: Select all
<div class="qanswer_tf">
    <tr>
      <td align="left"><input name="qanswer_a" type="text" size="60"></td>
      <td align="center"><input id="qanswer_tf[]" name="qanswer_tf[]" type="checkbox" value="a_true"></td>
    </tr>
    <tr>
      <td align="left"><input name="qanswer_b" type="text" size="60"></td>
      <td align="center"><input id="qanswer_tf[]" name="qanswer_tf[]" type="checkbox" value="b_true"></td>
    </tr>
    <tr>
      <td align="left"><input name="qanswer_c" type="text" size="60"></td>
      <td align="center"><input id="qanswer_tf[]" name="qanswer_tf[]" type="checkbox" value="c_true"></td>
    </tr>
    <tr>
      <td align="left"><input name="qanswer_d" type="text" size="60"></td>
      <td align="center"><input id="qanswer_tf[]" name="qanswer_tf[]" type="checkbox" value="d_true"></td>
    </tr>
    <tr>
      <td align="left"><input name="qanswer_e" type="text" size="60"></td>
      <td align="center"><input id="qanswer_tf[]" name="qanswer_tf[]" type="checkbox" value="e_true"></td>
    </tr>
</div>
<br><br>Post edited by: GreyHead, at: 2008/04/29 11:08
nosins
Fresh Boarder
 
Posts: 14
Joined: Sun Apr 20, 2008 1:42 am

Re:Required fields and radiobuttons

Postby GreyHead on Tue Apr 29, 2008 3:22 pm

Hi nosins,

This is a bit unusual in that there are 'input' fields and 'radio' fields interspersed. That may give the code hiccups. Worth a try though . . . I think it should look like:
Code: Select all
<div class="qanswer_tf">
  <input name="qanswer_a" type="text" size="60" />
  <input id="qanswer_tfa" name="qanswer_tf[]" type="checkbox" value="a_true" />
  <input name="qanswer_b" type="text" size="60" />
  <input id="qanswer_tfb" name="qanswer_tf[]" type="checkbox" value="b_true" />
  <input name="qanswer_c" type="text" size="60" />
  <input id="qanswer_tfc" name="qanswer_tf[]" type="checkbox" value="c_true" />
  <input name="qanswer_d" type="text" size="60" />
  <input id="qanswer_tfd" name="qanswer_tf[]" type="checkbox" value="d_true" />
  <input name="qanswer_e" type="text" size="60" />
  <input id="qanswer_tfe" name="qanswer_tf[]" type="checkbox" value="e_true" class="validate-one-required" />
</div>
I removed the table code for clarity, and made the field ids unique.

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3253
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Required fields and radiobuttons

Postby nosins on Tue Apr 29, 2008 6:22 pm

Thansk for giving it a shot Bob, but unfortunately... no luck.

The only thing that changed was that the form now requires that the last checkbox is checked rather that all checkboxes being checked. If I check the first checkbox, the last checkbox still shows-up as required and the form will not submit without it being checked first.

Thanks again for your effort,

Nick.
nosins
Fresh Boarder
 
Posts: 14
Joined: Sun Apr 20, 2008 1:42 am

Re:Required fields and radiobuttons

Postby admin on Thu May 01, 2008 5:33 am

try this fix here.
ChronoForms/ChronoConnectivity/ChronoComments Developer Thanks for using our components!
If you have any problems with any extension please tell us.
If you like any of our extensions please post a review at Joomla.org
Want users to submit their content to your website ? try Submit Story
Want to list/edit/delete your data ? try ChronoConnectivity
Want to have stylish AJAX comments ? try ChronoComments
User avatar
admin
Platinum Boarder
 
Posts: 2330
Joined: Mon Aug 14, 2006 5:29 am

Re:Required fields and radiobuttons

Postby nosins on Thu May 01, 2008 6:27 pm

Thanks again for the help.

Forgive me, though, but I don't understand how to use this example. This goes in the javascript form code field? In the case where I use a form like mine (copied below), with a checkbox field name qanswer_tf[] (so that I can get all the values passed), it doesn't seem to do anything.

Code: Select all
<div class='qanswer_tf'>
    <tr>
      <td align='left'><input name='qanswer_a' type='text' size='60' /></td>
      <td align='center'><input id='qanswer_tfa' name='qanswer_tf[]' type='checkbox' value='a_true' /></td>
    </tr>
    <tr>
      <td align='left'><input name='qanswer_b' type='text' size='60' /></td>
      <td align='center'><input id='qanswer_tfb' name='qanswer_tf[]' type='checkbox' value='b_true' /></td>
    </tr>
    <tr>
      <td align='left'><input name='qanswer_c' type='text' size='60' /></td>
      <td align='center'><input id='qanswer_tfc' name='qanswer_tf[]' type='checkbox' value='c_true' /></td>
    </tr>
    <tr>
      <td align='left'><input name='qanswer_d' type='text' size='60' /></td>
      <td align='center'><input id='qanswer_tfd' name='qanswer_tf[]' type='checkbox' value='d_true' /></td>
    </tr>
    <tr>
      <td align='left'><input name='qanswer_e' type='text' size='60' /></td>
      <td align='center'><input id='qanswer_tfe' name='qanswer_tf[]' type='checkbox' value='e_true' /></td>
    </tr>
</div>


I don't understand what 'elm' is in that example.

Thanks again,

Nick.
nosins
Fresh Boarder
 
Posts: 14
Joined: Sun Apr 20, 2008 1:42 am

Re:Required fields and radiobuttons

Postby admin on Sat May 03, 2008 1:47 am

Hi Nick,

The fix is to edit the validation file, moovalidation.js under components/com_chronocontact/js/ :) nothing to do with ur form code at all!

Sincerely,

Max
ChronoForms/ChronoConnectivity/ChronoComments Developer Thanks for using our components!
If you have any problems with any extension please tell us.
If you like any of our extensions please post a review at Joomla.org
Want users to submit their content to your website ? try Submit Story
Want to list/edit/delete your data ? try ChronoConnectivity
Want to have stylish AJAX comments ? try ChronoComments
User avatar
admin
Platinum Boarder
 
Posts: 2330
Joined: Mon Aug 14, 2006 5:29 am

Next

Return to ChronoForms How To

Who is online

Users browsing this forum: No registered users and 1 guest

cron