Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 选择2个选择标签后启用按钮_Javascript_Php_Jquery_Html_Ajax - Fatal编程技术网

Javascript 选择2个选择标签后启用按钮

Javascript 选择2个选择标签后启用按钮,javascript,php,jquery,html,ajax,Javascript,Php,Jquery,Html,Ajax,我正在做一个验证按钮。我有一个按钮,最初处于禁用状态。我有三个元素作为按钮启用码。1是输入标记,1是选择标记,另1是选择标记。填充并选择这3个元素后,应启用该按钮,当一个或所有元素返回空白时,应再次禁用该按钮 这就是我到目前为止所做的,但它不起作用。请帮帮我 $(window).load(function(){ $("#devicemask").on('keyup blur', function(){ $('#set-sr-property').prop('enable

我正在做一个验证按钮。我有一个按钮,最初处于禁用状态。我有三个元素作为按钮启用码。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);
                }   
            });
        });

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

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()
中,但没有成功。我不知道为什么。因此,
$.ready()
可能适合此项。

请详细说明..哦,您需要检查每个事件中元素的每个值。