Last active
March 30, 2023 02:17
-
-
Save Acephalia/8d12c7336b6e26cb8dd688e3ed3ac54c to your computer and use it in GitHub Desktop.
Disable search submit if field is empty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Change #searchform and #search to match your form fields. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
$(document).ready(function() { | |
$('#searchform').submit(function() { | |
if ($('#search').val().length === 0) { | |
return false; | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment