Validating a radio button is checked with jQuery

前端 未结 7 1783
你的背包
你的背包 2021-01-13 07:17

On my form I havea set of radio buttons. Here\'s the mark up:

Format

7条回答
  •  我在风中等你
    2021-01-13 07:41

    You can use the length and equal attribute selector with :checked filter selector like this:

    if ($("input[name='fileType']:checked").length > 0){
      // one ore more checkboxes are checked
    }
    else{
     // no checkboxes are checked
    }
    

提交回复
热议问题