Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

app-user-view-security.js 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * App User View - Security
  3. */
  4. 'use strict';
  5. document.addEventListener('DOMContentLoaded', function (e) {
  6. const formChangePass = document.querySelector('#formChangePassword'),
  7. phoneMask = document.querySelector('.phone-number-mask');
  8. // Form validation for Change password
  9. if (formChangePass) {
  10. const fv = FormValidation.formValidation(formChangePass, {
  11. fields: {
  12. newPassword: {
  13. validators: {
  14. notEmpty: {
  15. message: 'Please enter new password'
  16. },
  17. stringLength: {
  18. min: 8,
  19. message: 'Password must be more than 8 characters'
  20. }
  21. }
  22. },
  23. confirmPassword: {
  24. validators: {
  25. notEmpty: {
  26. message: 'Please confirm new password'
  27. },
  28. identical: {
  29. compare: function () {
  30. return formChangePass.querySelector('[name="newPassword"]').value;
  31. },
  32. message: 'The password and its confirm are not the same'
  33. },
  34. stringLength: {
  35. min: 8,
  36. message: 'Password must be more than 8 characters'
  37. }
  38. }
  39. }
  40. },
  41. plugins: {
  42. trigger: new FormValidation.plugins.Trigger(),
  43. bootstrap5: new FormValidation.plugins.Bootstrap5({
  44. eleValidClass: '',
  45. rowSelector: '.form-control-validation'
  46. }),
  47. submitButton: new FormValidation.plugins.SubmitButton(),
  48. // Submit the form when all fields are valid
  49. // defaultSubmit: new FormValidation.plugins.DefaultSubmit(),
  50. autoFocus: new FormValidation.plugins.AutoFocus()
  51. },
  52. init: instance => {
  53. instance.on('plugins.message.placed', function (e) {
  54. if (e.element.parentElement.classList.contains('input-group')) {
  55. e.element.parentElement.insertAdjacentElement('afterend', e.messageElement);
  56. }
  57. });
  58. }
  59. });
  60. }
  61. // phone number formatting
  62. if (phoneMask) {
  63. phoneMask.addEventListener('input', event => {
  64. const cleanValue = event.target.value.replace(/\D/g, '');
  65. phoneMask.value = formatGeneral(cleanValue, {
  66. blocks: [3, 3, 4],
  67. delimiters: [' ', ' ']
  68. });
  69. });
  70. registerCursorTracker({
  71. input: phoneMask,
  72. delimiter: ' '
  73. });
  74. }
  75. });