jQuery disable/enable submit button

后端 未结 21 3419
难免孤独
难免孤独 2020-11-22 07:30

I have this HTML:



How can I do something li

21条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 07:53

    $(function() {
      $(":text").keypress(check_submit).each(function() {
        check_submit();
      });
    });
    
    function check_submit() {
      if ($(this).val().length == 0) {
        $(":submit").attr("disabled", true);
      } else {
        $(":submit").removeAttr("disabled");
      }
    }
    

提交回复
热议问题