Ruby on Rails Friday, October 17, 2014



On Friday, 17 October 2014 03:46:49 UTC-4, M,Gopi M.gopinath wrote:
Hi,

I need to add a required class in gender radio button. How this can be done.

<td colspan="2">
<label for="stay_connected_form_gender">I am <span class="astris">*</span></label>
<%= f.radio_button :gender, 'm', :class => 'RadioInput' %>Male
<%= f.radio_button :gender, 'f', :class => 'RadioInput' %>Female
</td>

classname  = required

If I am adding like this then it display two validation message for each radio button.

<%= f.radio_button :gender, 'm', :class => 'RadioInput required' %>Male
<%= f.radio_button :gender, 'f', :class => 'RadioInput required' %>Female

I need to get a single validation msg if none of the radio button is selected.


What Colin said - there's not a single "element" for radio buttons. You didn't state which Javascript library you're using, but presumably it has a solution for radio buttons.

Also note that the ability to not have any of them checked is widely supported among browsers but not in keeping with the standard:


--Matt Jones

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2071bffc-05e4-4956-bb51-f667fe8e0a16%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment