Skip to content

Instantly share code, notes, and snippets.

@LeoLopesWeb
Created August 29, 2018 18:18
Show Gist options
  • Select an option

  • Save LeoLopesWeb/0d0dbfbba17d9d32a7ea74585f36169f to your computer and use it in GitHub Desktop.

Select an option

Save LeoLopesWeb/0d0dbfbba17d9d32a7ea74585f36169f to your computer and use it in GitHub Desktop.
desabilitar submit se o campo estiver vazio
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
// By default submit is disabled
$('.btn').prop('disabled', true);
$('.search').keyup(function() {
if($(this).val().length !=0 ) {
$('.btn').prop('disabled', false);
} else {
$( ".search").focus();
$('.btn').prop('disabled', true);
e.preventDefault();
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment