説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

modal-enable-otp.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Enable OTP
  3. */
  4. 'use strict';
  5. document.addEventListener('DOMContentLoaded', function (e) {
  6. (function () {
  7. const phoneMask = document.querySelector('.phone-number-otp-mask');
  8. // Phone Number Input Mask
  9. if (phoneMask) {
  10. phoneMask.addEventListener('input', event => {
  11. const cleanValue = event.target.value.replace(/\D/g, '');
  12. phoneMask.value = formatGeneral(cleanValue, {
  13. blocks: [3, 3, 4],
  14. delimiters: [' ', ' ']
  15. });
  16. });
  17. registerCursorTracker({
  18. input: phoneMask,
  19. delimiter: ' '
  20. });
  21. }
  22. // Enable OTP form validation
  23. FormValidation.formValidation(document.getElementById('enableOTPForm'), {
  24. fields: {
  25. modalEnableOTPPhone: {
  26. validators: {
  27. notEmpty: {
  28. message: 'Please enter your mobile number'
  29. }
  30. }
  31. }
  32. },
  33. plugins: {
  34. trigger: new FormValidation.plugins.Trigger(),
  35. bootstrap5: new FormValidation.plugins.Bootstrap5({
  36. // Use this for enabling/changing valid/invalid class
  37. // eleInvalidClass: '',
  38. eleValidClass: '',
  39. rowSelector: '.form-control-validation'
  40. }),
  41. submitButton: new FormValidation.plugins.SubmitButton(),
  42. // Submit the form when all fields are valid
  43. // defaultSubmit: new FormValidation.plugins.DefaultSubmit(),
  44. autoFocus: new FormValidation.plugins.AutoFocus()
  45. },
  46. init: instance => {
  47. instance.on('plugins.message.placed', function (e) {
  48. //* Move the error message out of the `input-group` element
  49. if (e.element.parentElement.classList.contains('input-group')) {
  50. e.element.parentElement.insertAdjacentElement('afterend', e.messageElement);
  51. }
  52. });
  53. }
  54. });
  55. })();
  56. });