Guest User

Untitled

a guest
Aug 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. Check empty value for all fields
  2. <form action="abc.html" method="POST" class="submit">
  3. <input type="text" name="name"><br>
  4. <input type="text" name="name"><br>
  5. <input type="text" name="name"><br>
  6. <button id="cli">Submit</button>
  7. </form>
  8.  
  9.  
  10.  
  11. $('.submit').submit(function() {
  12. var input = $(this).closest('form').find('input[type="text"]');
  13. if (!$(input).val()){
  14. var cssObj={'border-radius':'5px',border:"none","box-shadow":"0 0 1px 1px red",outline:"none",background:"#ffc4c4"};
  15. $('input[type="text"]').css(cssObj);
  16. return false;
  17. };
  18. });
  19.  
  20. $('.submit').submit(function() {
  21. var input = $(this).closest('form').find('input[type="text"]');
  22. var result = true;
  23. input.each(function(){
  24. if (!$(this).val()){
  25. var cssObj={'border-radius':'5px',border:"none","box-shadow":"0 0 1px 1px red",outline:"none",background:"#ffc4c4"};
  26. $(this).css(cssObj);
  27. result = false;
  28. };
  29. });
  30. return result;
  31. });
Add Comment
Please, Sign In to add comment