javascript - Do not search if the search field is empty (Wordpress) -


i have basic wordpress search form, don't want users able search if leave search field blank, preferably javascript, how done?

(function() { $('form > input').keyup(function() {      var empty = false;     $('form > input').each(function() {         if ($(this).val() == '') {             empty = true;         }     });      if (empty) {         $('#search').attr('disabled', 'disabled');     } else {         $('#search').removeattr('disabled');     } }); })(); 

and remember disable button default:

<input type="submit" id="search" value="search" disabled="disabled" /> 

answer taken previous stack overflow question: disabling submit button until fields have values


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -