On 17 October 2014 08:46, M,Gopi M.gopinath <[email protected]> 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.
Asssuming that the second one is for css purposes (or similar) then it would be better to move the class out to a surrounding element, the td, tr or even form for example. Colin -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtPV6Gau1yBnLrnc6EdBwUWqQOn16TT--5HrovbqdjUjA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

