Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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
Jquery 如果输入了类型编号或类型文件,则启用按钮_Jquery - Fatal编程技术网

Jquery 如果输入了类型编号或类型文件,则启用按钮

Jquery 如果输入了类型编号或类型文件,则启用按钮,jquery,Jquery,我只需要在其他输入被填充的情况下启用一些按钮,这适用于文本类型的输入,但不适用于数字和文件类型的输入 请参阅jsfiddle: 为什么它不起作用?number或file类型的输入字段没有长度 Jsp: 他们有一个长度,但不是一个onkeyup事件。只需将事件更改为.change(),而不是.keyup(): 这两种方法都有效。谢谢,我没有想到这种可能性 <input type="file" id="file"/> <input type="button" id="load-fi

我只需要在其他输入被填充的情况下启用一些按钮,这适用于文本类型的输入,但不适用于数字和文件类型的输入

请参阅jsfiddle:

为什么它不起作用?number或file类型的输入字段没有长度

Jsp:


他们有一个长度,但不是一个onkeyup事件。只需将事件更改为
.change()
,而不是
.keyup()


这两种方法都有效。

谢谢,我没有想到这种可能性
<input type="file" id="file"/>
<input type="button" id="load-file" value="submit"/>
<br/>
<input type="number" id="insertAnno"/>
<input type="button" id="whenCustom" value="submit"/>
<br/>
<input type="text" id="text"/>
<input type="button" id="textInput" value="submit"/>
$(document).ready(function(){
    $('#load-file').attr('disabled',true);

    $('#file').keyup(function(){
        if($(this).val().length !=0){
            $('#load-file').attr('disabled', false);
        }
        else
        {
            $('#load-file').attr('disabled', true);        
        }
    });

    $('#whenCustom').attr('disabled',true);

    $('#insertAnno').keyup(function(){
        if($(this).val().length !=0){
            $('#whenCustom').attr('disabled', false);
        }
        else
        {
            $('#whenCustom').attr('disabled', true);        
        }
    });

    $('#textInput').attr('disabled',true);

    $('#text').keyup(function(){
        if($(this).val().length !=0){
            $('#textInput').attr('disabled', false);
        }
        else
        {
            $('#textInput').attr('disabled', true);        
        }
    });
});
$('#insertAnno').change(...
$('#file').change(...