jQuery validate only if a specific radio button is selected

前端 未结 1 1122
一生所求
一生所求 2021-02-08 03:17

I got stuck at a particular situation

I have 2 radio buttons

Yes


        
相关标签:
1条回答
  • 2021-02-08 03:39

    You can set up dependency validation as seen here http://docs.jquery.com/Plugins/Validation/Methods/required#dependency-expression

    $('#myForm').validate(rules: {
       price: { 
         required: '#sub[value="YES"]:checked'
        }
    });
    
    0 讨论(0)
提交回复
热议问题