jQuery disable/enable submit button

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

I have this HTML:



How can I do something li

21条回答
  •  天命终不由人
    2020-11-22 07:47

    It will work like this:

    $('input[type="email"]').keyup(function() {
        if ($(this).val() != '') {
            $(':button[type="submit"]').prop('disabled', false);
        } else {
            $(':button[type="submit"]').prop('disabled', true);
        }
    });
    

    Make sure there is an 'disabled' attribute in your HTML

提交回复
热议问题