Created
August 29, 2018 18:18
-
-
Save LeoLopesWeb/0d0dbfbba17d9d32a7ea74585f36169f to your computer and use it in GitHub Desktop.
desabilitar submit se o campo estiver vazio
This file contains hidden or 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 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