/** * Pages Authentication */ 'use strict'; document.addEventListener('DOMContentLoaded', function () { (() => { const formAuthentication = document.querySelector('#formAuthentication'); // Form validation for Add new record if (formAuthentication && typeof FormValidation !== 'undefined') { FormValidation.formValidation(formAuthentication, { fields: { username: { validators: { notEmpty: { message: 'Inserisci il nome utente' }, stringLength: { min: 6, message: 'Il nome utente deve essere più lungo di 6 caratteri' } } }, email: { validators: { notEmpty: { message: 'Inserisci il tuo indirizzo email' }, emailAddress: { message: 'Inserisci un indirizzo email valido' } } }, 'email-username': { validators: { notEmpty: { message: 'Inserisci email / nome utente' }, stringLength: { min: 6, message: 'Il nome utente deve essere più lungo di 6 caratteri' } } }, password: { validators: { notEmpty: { message: 'Inserisci la password' }, stringLength: { min: 6, message: 'La password deve essere più lunga di 6 caratteri' } } }, 'confirm-password': { validators: { notEmpty: { message: 'Conferma la password' }, identical: { compare: () => formAuthentication.querySelector('[name="password"]').value, message: 'La password e la sua conferma non corrispondono' }, stringLength: { min: 6, message: 'La password deve essere più lunga di 6 caratteri' } } }, terms: { validators: { notEmpty: { message: 'Accetta i termini e le condizioni' } } } }, plugins: { trigger: new FormValidation.plugins.Trigger(), bootstrap5: new FormValidation.plugins.Bootstrap5({ eleValidClass: '', rowSelector: '.form-control-validation' }), submitButton: new FormValidation.plugins.SubmitButton(), defaultSubmit: new FormValidation.plugins.DefaultSubmit(), autoFocus: new FormValidation.plugins.AutoFocus() }, init: instance => { instance.on('plugins.message.placed', e => { if (e.element.parentElement.classList.contains('input-group')) { e.element.parentElement.insertAdjacentElement('afterend', e.messageElement); } }); } }); } // Two Steps Verification for numeral input mask const numeralMaskElements = document.querySelectorAll('.numeral-mask'); // Format function for numeral mask const formatNumeral = value => value.replace(/\D/g, ''); // Only keep digits if (numeralMaskElements.length > 0) { numeralMaskElements.forEach(numeralMaskEl => { numeralMaskEl.addEventListener('input', event => { numeralMaskEl.value = formatNumeral(event.target.value); }); }); } })(); });