jquery - My search button gets disable when i move down using tab or keys from input text field to select dropdown -
i have 4 fields out of first 2 input fields , last 2 select dropdown.the issue facing here when try move down input field select dropdown using tab key or normally,my search button gets disabled because of disable attribute getting added.i tried implementing not working.the code working fine input field keyup function.i not have common class select , input else have used $('.class').on('keyup change', function ()).how achieve that.".select_group" class last 2 select dropdowns.
if(jquery.trim($emailadd.val()) != "" || jquery.trim($fidadd.val()) != "" || jquery.trim($mnqadd.val()) != "") $('#btn_search').attr('disabled',false); else $('#btn_search').attr('disabled',true); $('input[type="text"],.select_group').on('keyup change click', function () { if($(this).val() != '') { $('input[type="submit"]').removeattr('disabled'); } }); i have added lines make work not working input text fields.
$('input[type="text"],.select_group').on('keyup change click', function () { if($(this).val() != '') { $('input[type="submit"]').removeattr('disabled'); } }); let me know how make work input text fields , select dropdowns when move down using key or tab.please help.
you can try this:
$('input[type="submit"]').prop("disabled", false); this propagates in dom property. if not problem, please, make jsfiddle reproduce it.
edit
what's content of $(this).val() ?? know it?
edit 2
if code:
if(jquery.trim($emailadd.val()) != "" || jquery.trim($fidadd.val()) != "" || jquery.trim($mnqadd.val()) != "") $('#btn_search').attr('disabled',false); else $('#btn_search').attr('disabled',true); $('input[type="text"],.select_group').on('keyup change click', function () { if($(this).val() != '') { $('input[type="submit"]').removeattr('disabled'); } }); you must learn how if-else statements needs brackets {} limit functionality. works:
if(jquery.trim($emailadd.val()) != "" || jquery.trim($fidadd.val()) != "" || jquery.trim($mnqadd.val()) != "") { $('#btn_search').attr('disabled',false); } else { $('#btn_search').attr('disabled',true); $('input[type="text"], .select_group').on('keyup change click', function () { if($(this).val() != '') { $('input[type="submit"]').removeattr('disabled'); } }); }
Comments
Post a Comment