选择2选择标记时启用按钮

时间:2016-04-12 15:57:54

标签: javascript php jquery html ajax

我正在做验证按钮。我有一个最初处于禁用状态的按钮。我有三个元素作为按钮启用器。 1是输入标签,1是选择标签,另1是选择标签。当填充并选择这些3时,应该启用该按钮,并在一个或所有元素返回空白时再次返回禁用状态。

这是我到目前为止所做的事情,它不起作用。请帮帮我

$(window).load(function(){

    $("#devicemask").on('keyup blur', function(){
        $('#set-sr-property').prop('enabled', this.value.trim().length);
    });

            $('#flightselect').change(function() {
                var op =$(this).val();
                if(op ! = '') {                 
                    $('#set-sr-property').prop('disabled',false);
                } else {
                      $('#set-sr-property').prop('disabled', true);
                }   
            });

            $('#crewselect').change(function() {
                var op =$(this).val();
                if(op ! = '') {                 
                    $('#set-sr-property').prop('disabled',false);
                } else {
                      $('#set-sr-property').prop('disabled', true);
                }   
            });
        });

1 个答案:

答案 0 :(得分:0)

您需要检查每个事件之间的每个值。基本上会是这样的。

   $token = openssl_random_pseudo_bytes(16);
   $ticket = bin2hex($token);

你确定可以简化它。示例小提琴requests

无论如何,我试图将它包装在var input = $('#devicemask'); var select1 = $('#flightselect'); var select2 = $('#crewselect'); var button = $('#set-sr-property'); input.on('keyup blur', function(){ if (input.val().trim().length >= 1 && select1.val() !== '' && select2.val() !== '') { button.prop('disabled', false); }else{ button.prop('disabled', true); } }); select1.change(function() { if (input.val().trim().length >= 1 && select1.val() !== '' && select2.val() !== '') { button.prop('disabled', false); }else{ button.prop('disabled', true); } }); select2.change(function() { if (input.val().trim().length >= 1 && select1.val() !== '' && select2.val() !== '') { button.prop('disabled', false); }else{ button.prop('disabled', true); } }); 内但不起作用。我不知道为什么。所以$.load()可能适用于此。