WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
[resolved] How do I make a radio button REQUIRED? (6 posts)

  1. mjefferson96
    Member
    Posted 1 year ago #

    Text fields I can require but I canonot require radio buttons. Any idea how to do ths?

    http://wordpress.org/extend/plugins/contact-form-7/

  2. davejampole
    Member
    Posted 1 year ago #

    If you read this <http://contactform7.com/checkboxes-radio-buttons-and-menus/>, you'll see that by their very nature, radio buttons are required.

  3. mjefferson96
    Member
    Posted 1 year ago #

    The problem is that the radio button are NOT required when I hit SEND without filling in a selection, it sends just fine with NO value. So no, that does not help at all if I do not want to add a default value.
    As it stands now I will simply add " default:1 " before the first radio selection just so that will be required to leave it or change it.

  4. davejampole
    Member
    Posted 1 year ago #

    Just going by what the docs say. Sounds like it's time for the CF7 creator to jump on this.

  5. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 1 year ago #

    Just as the doc says, radio buttons are "required" by nature. Setting a default value is always a good practice. When you don't want to set a default option, you can use checkbox* tag with exclusive option instead. It behaves like radio buttons, but still works as checkboxes.

    for more detail
    Checkboxes, Radio Buttons and Menus

  6. nztim
    Member
    Posted 1 year ago #

    I just had a look at the latest HTML5 spec for this and it looks different than the older version:

    http://www.w3.org/html/wg/drafts/html/master/forms.html#radio-button-state-(type=radio)

    Constraint validation: If an element in the radio button group is required, and all of the input elements in the radio button group have a checkedness that is false, then the element is suffering from being missing.

    With respect Takayuki, checkboxes don't look exclusive, so making them exclusive for some questions is confusing and unnecessary - that's what radio buttons are for.

    Take the example of a gender question - radio buttons are the obvious choice, having checkboxes would be downright weird because of their non-exclusive appearance. If it's an important and required question, making one radio button option pre-selected is a recipe for unreliable results.

    Thanks for an awesome plugin!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic