Hi I am trying make a search button active/inactive based on whether the user has entered text into BOTH textboxes. Currently it is becoming active when the user enters text on only the first box. Can anyone please tell me what I am doing wrong?? Thanks in advance!
$(".searchBtn.active").hide();
$(".searchBtn.inactive").prop('disabled', true);
$.each($(".searchFormContent input[type=text]"), function () {
$(this).keyup(function () {
if ($(this).val().length > 0) {
$(".searchBtn.inactive").hide();
$(".searchBtn.active").show();
} else {
$(".searchBtn.active").hide();
$(".searchBtn.inactive").show();
}
});
});
I have now tried this:
$(".searchFormContent input[type=text]").each(function () {
$(this).keyup(function () {
if ($(this).val().length > 0) {
$(".searchBtn.inactive").hide();
$(".searchBtn.active").show();
} else {
$(".searchBtn.active").hide();
$(".searchBtn.inactive").show();
}
})
});
and this:
$(".searchFormContent input[type=text]").keyup(function () {
if ($(this).val().length > 0) {
$(".searchBtn.inactive").hide();
$(".searchBtn.active").show();
} else {
$(".searchBtn.active").hide();
$(".searchBtn.inactive").show();
}
});
Getting the same result every time.