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

  1. mjefferson96
    Posted 2 years ago #

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


  2. davejampole
    Posted 2 years 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
    Posted 2 years 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
    Posted 2 years ago #

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

  5. Takayuki Miyoshi
    Plugin Author

    Posted 2 years 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
    Posted 2 years ago #

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


    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

  • Contact Form 7
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic