Moti Mashiah
asked on
Jquery
Hi Guys,
I have keyup method and I disable button when textbox is empty look at the code below:
the issue I have here is when user enter space it is also enable for them the button. How do I give statement to allow user to enable the button just when the put characters in the textbox no spaces.?
I have keyup method and I disable button when textbox is empty look at the code below:
the issue I have here is when user enter space it is also enable for them the button. How do I give statement to allow user to enable the button just when the put characters in the textbox no spaces.?
$(document).ready(function () {
$("#Upctextid").keyup(function () {
if ($(this).val() != " ") {
$("#activate-step-2").removeAttr('disabled');
} else {
$("#activate-step-2").attr('disabled', 'disabled');
}
})
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I didn't use blur as it is didn't work in a time user type in the box
$("#Upctextid").keyup(func
//get the current fields DOM element
var myVal = $(this)[0];
//strip all of the spaces from the field's value and see if it is empty
if (myVal.value.replace(/ /g, '') === "") {
$("#activate-step-2").prop
} else {
$("#activate-step-2").prop
}
});