Reputation: 9
In the $(':text').keyup(function() {
I tried changing the :text into :number doesn't work only works if I remove the && $('#number').val() != ""
<script>
$(document).ready(function(event) {
$(':text').keyup(function() {
if($('#input').val() != "" && $('#number').val() != ""
){
$('#submit').removeAttr('disabled');
} else {
$('#submit').attr('disabled', true);
}
});});
</script>
<form><input type=text id='input'>
<input type=number id='number'><br>
<input type=button id='submit' value='submit'>
</form>
jsfiddle: http://jsfiddle.net/LaLL0v6a/
Upvotes: 0
Views: 2662
Reputation: 388436
There are 2 problems.
so
$(document).ready(function (event) {
$('#input, #number').keyup(function () {
$('#submit').prop('disabled', $('#input').val() == '' || $('#number').val() == "");
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type=text id='input' />
<input type=number id='number' />
<input type=button id='submit' value='submit' disabled />
Upvotes: 2
Reputation: 1876
Use
$('#input').keyup(function() {
or
$('input[type="text"]').keyup(function() {
instead of
$(':text').keyup(function() {
Upvotes: 2