Advertisement
arijulianto

jQuery CSS Disable & Enabled Button dengan Text

Aug 7th, 2014
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.82 KB | None | 0 0
  1. <style>
  2. #msg{
  3.     font-family:arial;
  4.     font-size:13px;
  5.     color:#333;
  6.     border: 1px solid #999;
  7.     padding:3px;
  8.     margin:0;
  9. }
  10. #kirim,#reset{
  11.     border:1px solid #999;
  12.     background:#088000;
  13.     color:#fff;
  14.     font-family:arial;
  15.     font-size:13px;
  16.     display:inline-block;
  17.     margin:0;
  18.     padding:6px 12px;
  19. }
  20. #kirim[disabled]{
  21.     color:#999;
  22.     background:#4B6146;
  23. }
  24. </style>
  25. <script src="https://code.jquery.com/jquery-1.8.3.min.js"></script>
  26. <script>
  27. $(function(){
  28. $('#msg').keyup(function(){
  29.     if($(this).val().length>0){
  30.         $('#kirim').attr('disabled',false);
  31.     }else{
  32.         $('#kirim').attr('disabled',true);
  33.     }
  34. });
  35. });
  36. </script>
  37. <form>
  38. <textarea id="msg" cols=20 rows=3></textarea><br />
  39. <input id="reset" type="reset" class="button" value="Hapus" />
  40. <input id="kirim" type="submit" class="button" value="Kirim" disabled />
  41. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement