Adding validations to see if radio button is not selected

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

I have the following code:

 
  • 1. question 1
  • Strongly
  • 8条回答
    •  温柔的废话
      2021-01-07 06:51

      Something like this?

      if ($('input[type=radio]:checked').length <= 0) {
          alert("No radio checked")
      }
      

      Or do it by name?

      if ($('input[name=question1]:checked').length <= 0) {
          alert("No radio checked")
      }
      

    提交回复
    热议问题