Advertisement
oquidave

js_form_validation

Apr 20th, 2014
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //html
  2. <form id="quiz_form" action="?page={{ qn_page.next_page_number }}" method="post" >
  3.  <! --my form elemements here -->
  4.  <input type="submit" class="btn btn-primary btn-large" value="Next Question">
  5. </form>
  6.  
  7. //js
  8. $(function(){
  9.         //validate quiz form
  10.        
  11.         $('#quiz_form').submit(function (e) {
  12.           validate_quiz_form(e);
  13.       });
  14.  
  15.     });
  16.  
  17. function validate_quiz_form(e){
  18.       e.preventDefault();
  19.       var len = $('#quiz_form input:radio:checked').length;
  20.       if (!len) {
  21.         alert("None checked");
  22.         return;
  23.       }
  24.       $("#quiz_form").submit();
  25.       //$(this).submit();
  26.     }
  27. //chrome console
  28. Uncaught RangeError: Maximum call stack size exceeded
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement