Guest User

Untitled

a guest
Jan 2nd, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.78 KB | None | 0 0
  1. $('.login-form').validate ({
  2. // validation rules for registration form
  3. errorClass: "error-class",
  4. validClass: "valid-class",
  5. onError : function(){
  6. $('.input-group.error-class').find('.help-block.form-error').each(function() {
  7. $(this).closest('.form-group').addClass('error-class').append($(this));
  8. });
  9. },
  10.  
  11. rules: {
  12. username: {
  13. required: true,
  14. minlength: 3,
  15. maxlength: 40
  16. },
  17.  
  18. password: {
  19. required: true,
  20. minlength: 7,
  21. maxlength: 20
  22. }
  23. },
  24.  
  25. messages: {
  26. username: {
  27. required: "Please enter your username or email address",
  28. minlength: "Usernames can't be shorter than three characters",
  29. maxlength: "Usernames or emails must be shorter than forty characters."
  30. },
  31. password: {
  32. required: "Please enter your password",
  33. minlength: "Passwords can't be shorter than seven characters",
  34. maxlength: "Passwords must be shorter than forty characters."
  35. },
  36.  
  37. highlight: function(element, errorClass) {
  38. $(element).removeClass(errorClass);
  39. }
  40. },
  41.  
  42. submitHandler: function() {
  43. $('#noenter').show();
  44.  
  45. }
  46. });
  47.  
  48. <!-- Modal -->
  49. <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  50. <form class="login-form" action="login" method="post" action="../PHP/ValidateForm.php">
  51. <div class="modal-dialog" role="document">
  52. <div class="modal-content">
  53. <div class="modal-header">
  54. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  55. <h4 class="modal-title" style="color:red;" id="myModalLabel">TITLE</h4>
  56. </div>
  57. <div class="modal-body">
  58. <!-- Text input-->
  59. <div class="form-group">
  60.  
  61. <div class="input-group">
  62. <span class="input-group-addon"><i class="fa fa-2x fa-user"></i></span>
  63. <input required id="username" name="username" placeholder="Username or Email" class="inputfield form-control" type="text">
  64.  
  65.  
  66. </div>
  67. </div>
  68.  
  69. <!-- Text input-->
  70. <div class="form-group">
  71.  
  72. <div class="input-group">
  73. <span class="input-group-addon"><i class="fa fa-2x fa-lock"></i></span>
  74. <input required id="password" name="password" placeholder="Password" class="form-control" type="password">
  75.  
  76.  
  77. </div>
  78. </div>
  79. <div class="error">
  80.  
  81. </div>
  82. <input title="Log In" name="submit" value="Log In" type="submit" class="loginbtn btn btn-lg btn-block">
  83. </div>
  84.  
  85. <p class="text-muted"><strong>Need an account? <a href="#">Join </a></strong>
  86.  
  87. </p>
  88.  
  89.  
  90. </div>
  91. </div>
  92. </form>
  93. </div>
  94.  
  95. .form-control {color:#000 !important;}
  96.  
  97.  
  98.  
  99. form label.error-class{font:15px Tahoma,sans-serif;color:#ED7476;margin-left:5px;position:relative;}
  100.  
  101. form input.error-class,form input.error-class:hover,form input.error:focus,form select.error-class,form textarea.error-class{background:#FFEDED; }
  102.  
  103. .error-class {
  104. color:red; z-index:0; position:relative; display:inline-block; }
  105.  
  106. .valid-class {
  107. color:black;
  108. }
  109.  
  110. $('.login-form').validate ({
  111.  
  112. // validation rules for registration form
  113. errorClass: "error-class",
  114. validClass: "valid-class",
  115. errorElement: 'div',
  116. errorPlacement: function(error, element) {
  117. if(element.parent('.input-group').length) {
  118. error.insertAfter(element.parent());
  119. } else {
  120. error.insertAfter(element);
  121. }
  122. },
  123. onError : function(){
  124. $('.input-group.error-class').find('.help-block.form-error').each(function() {
  125. $(this).closest('.form-group').addClass('error-class').append($(this));
  126. });
  127. },
  128.  
  129. rules: {
  130. username: {
  131. required: true,
  132. minlength: 3,
  133. maxlength: 40
  134. },
  135.  
  136. password: {
  137. required: true,
  138. minlength: 7,
  139. maxlength: 20
  140. }
  141. },
  142.  
  143. messages: {
  144. username: {
  145. required: "Please enter your username or email address",
  146. minlength: "Usernames can't be shorter than three characters",
  147. maxlength: "Usernames or emails must be shorter than forty characters."
  148. },
  149. password: {
  150. required: "Please enter your password",
  151. minlength: "Passwords can't be shorter than seven characters",
  152. maxlength: "Passwords must be shorter than forty characters."
  153. },
  154.  
  155. highlight: function(element, errorClass) {
  156. $(element).removeClass(errorClass);
  157. }
  158. },
  159.  
  160. submitHandler: function() {
  161. $('#noenter').show();
  162.  
  163. }
  164.  
  165. });
  166.  
  167. .error-class {
  168. color:red; z-index:0; position:relative; display:block; text-align: left; }
  169.  
  170. <div class="input-group">
  171. <i class="fa fa-2x fa-user"></i>
  172. <span class="input-group-addon"></span>
  173. <input required id="username" name="username" placeholder="Username or Email" class="inputfield form-control" type="text">
  174. </div>
  175.  
  176. $('#form-enroll').validate({
  177. ...
  178. errorPlacement: function(error, element) {
  179. $(element).parents('.form-group').append(error)
  180. },
  181. })
Add Comment
Please, Sign In to add comment