Skip to content

Instantly share code, notes, and snippets.

@Acephalia
Last active March 30, 2023 02:17
Show Gist options
  • Save Acephalia/8d12c7336b6e26cb8dd688e3ed3ac54c to your computer and use it in GitHub Desktop.
Save Acephalia/8d12c7336b6e26cb8dd688e3ed3ac54c to your computer and use it in GitHub Desktop.
Disable search submit if field is empty
Change #searchform and #search to match your form fields.
<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