LeoLopesWeb
8/29/2018 - 6:18 PM

desativar busca vazia

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>