op_auth_signin.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Document : op_auth_signin.js
  3. * Author : pixelcave
  4. * Description: Custom JS code used in Sign In Page
  5. */
  6. var OpAuthSignIn = function() {
  7. // Init Sign In Form Validation, for more examples you can check out https://github.com/jzaefferer/jquery-validation
  8. var initValidationSignIn = function(){
  9. jQuery('.js-validation-signin').validate({
  10. errorClass: 'invalid-feedback animated fadeInDown',
  11. errorElement: 'div',
  12. errorPlacement: function(error, e) {
  13. jQuery(e).parents('.form-group > div').append(error);
  14. },
  15. highlight: function(e) {
  16. jQuery(e).closest('.form-group').removeClass('is-invalid').addClass('is-invalid');
  17. },
  18. success: function(e) {
  19. jQuery(e).closest('.form-group').removeClass('is-invalid');
  20. jQuery(e).remove();
  21. },
  22. rules: {
  23. 'login-username': {
  24. required: true,
  25. minlength: 3
  26. },
  27. 'login-password': {
  28. required: true,
  29. minlength: 5
  30. }
  31. },
  32. messages: {
  33. 'login-username': {
  34. required: 'Please enter a username',
  35. minlength: 'Your username must consist of at least 3 characters'
  36. },
  37. 'login-password': {
  38. required: 'Please provide a password',
  39. minlength: 'Your password must be at least 5 characters long'
  40. }
  41. }
  42. });
  43. };
  44. return {
  45. init: function () {
  46. // Init Sign In Form Validation
  47. initValidationSignIn();
  48. }
  49. };
  50. }();
  51. // Initialize when page loads
  52. jQuery(function(){ OpAuthSignIn.init(); });