| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /**
- * Enable OTP
- */
-
- 'use strict';
-
- document.addEventListener('DOMContentLoaded', function (e) {
- (function () {
- const phoneMask = document.querySelector('.phone-number-otp-mask');
-
- // Phone Number Input Mask
- if (phoneMask) {
- phoneMask.addEventListener('input', event => {
- const cleanValue = event.target.value.replace(/\D/g, '');
- phoneMask.value = formatGeneral(cleanValue, {
- blocks: [3, 3, 4],
- delimiters: [' ', ' ']
- });
- });
- registerCursorTracker({
- input: phoneMask,
- delimiter: ' '
- });
- }
-
- // Enable OTP form validation
- FormValidation.formValidation(document.getElementById('enableOTPForm'), {
- fields: {
- modalEnableOTPPhone: {
- validators: {
- notEmpty: {
- message: 'Please enter your mobile number'
- }
- }
- }
- },
- plugins: {
- trigger: new FormValidation.plugins.Trigger(),
- bootstrap5: new FormValidation.plugins.Bootstrap5({
- // Use this for enabling/changing valid/invalid class
- // eleInvalidClass: '',
- eleValidClass: '',
- rowSelector: '.form-control-validation'
- }),
- submitButton: new FormValidation.plugins.SubmitButton(),
- // Submit the form when all fields are valid
- // defaultSubmit: new FormValidation.plugins.DefaultSubmit(),
- autoFocus: new FormValidation.plugins.AutoFocus()
- },
- init: instance => {
- instance.on('plugins.message.placed', function (e) {
- //* Move the error message out of the `input-group` element
- if (e.element.parentElement.classList.contains('input-group')) {
- e.element.parentElement.insertAdjacentElement('afterend', e.messageElement);
- }
- });
- }
- });
- })();
- });
|