Enable/Disable submit button if checkbox is checked/unchecked?

后端 未结 3 2078
Happy的楠姐
Happy的楠姐 2020-11-27 20:17

How to enable the submit button in my HTML form and disable if checkbox was unchecked?

What is wrong with this code?

EnableSubmit = function(val)
{
          


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 21:09

    First if condition checks whether toggle is switched to desired side. Condition can be changed according to requirement. Last jquery is to make toggle button grey.

     if(!$('#togglehk').is(":checked"))
                        {
                            $('#togglehk').click();
                        }
      jQuery('#togglehk').attr("disabled", true);
      jQuery('#togglehk').prop("disabled",true);
    
      jQuery('#togglehk').next(".slider").css("backgroundcolor","#B3B3B3");
    

提交回复
热议问题