Adding validations to see if radio button is not selected

前端 未结 8 1099
误落风尘
误落风尘 2021-01-07 06:30

I have the following code:

 
  • 1. question 1
  • Strongly
  • 8条回答
    •  鱼传尺愫
      2021-01-07 06:57

      Below code is more simple and clean for even biggners

      if (!$("input[name='html_elements']:checked").val()) {
         alert('Nothing is checked!');
      }
      else {
        alert('One of the radio buttons is checked!');
      }
      

      check out this below fiddle demo

      Visit http://jsfiddle.net/creators_guru/DBd79/

    提交回复
    热议问题