You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
4.1 KiB
113 lines
4.1 KiB
// $(document).ready(function() {
|
|
// // Fonction pour vérifier la syntaxe de l'email
|
|
// function validateEmail(email) {
|
|
// const regex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
|
|
// return regex.test(email);
|
|
// }
|
|
|
|
// // Fonction pour vérifier le numéro de téléphone
|
|
// function validatePhone(phone) {
|
|
// const regex = /^\d{10}$/; // Vérifie si le téléphone a 10 chiffres
|
|
// return regex.test(phone);
|
|
// }
|
|
|
|
// // Fonction pour valider le code postal
|
|
// function validatePostal(postal) {
|
|
// return postal.length === 5; // En supposant que le code postal a 5 chiffres
|
|
// }
|
|
|
|
// // Validation des champs au changement
|
|
// $('#beneficiaryForm input, #beneficiaryForm select').on('input change', function() {
|
|
// let isValid = true;
|
|
// let id = $(this).attr('id');
|
|
// let value = $(this).val();
|
|
|
|
// // Validation du champ civilité
|
|
// if (id === 'civilite' && value === '') {
|
|
// $('#error_civilite').text('Veuillez sélectionner une civilité.');
|
|
// isValid = false;
|
|
// } else {
|
|
// $('#error_civilite').text('');
|
|
// }
|
|
|
|
// // Validation du champ nom
|
|
// if (id === 'name' && value === '') {
|
|
// $('#error_name').text('Le nom est requis.');
|
|
// isValid = false;
|
|
// } else {
|
|
// $('#error_name').text('');
|
|
// }
|
|
|
|
// // Validation du champ prénom
|
|
// if (id === 'fname' && value === '') {
|
|
// $('#error_fname').text('Le prénom est requis.');
|
|
// isValid = false;
|
|
// } else {
|
|
// $('#error_fname').text('');
|
|
// }
|
|
|
|
// // Validation de l'email
|
|
// if (id === 'email') {
|
|
// if (value === '') {
|
|
// $('#error_email').text('L\'email est requis.');
|
|
// isValid = false;
|
|
// } else if (!validateEmail(value)) {
|
|
// $('#error_email').text('Veuillez entrer un email valide.');
|
|
// isValid = false;
|
|
// } else {
|
|
// $('#error_email').text('');
|
|
// }
|
|
// }
|
|
|
|
// // Validation de l'adresse
|
|
// if (id === 'address' && value === '') {
|
|
// $('#error_address').text('L\'adresse est requise.');
|
|
// isValid = false;
|
|
// } else {
|
|
// $('#error_address').text('');
|
|
// }
|
|
|
|
// // Validation du code postal
|
|
// if (id === 'postal') {
|
|
// if (value === '') {
|
|
// $('#error_postal').text('Le code postal est requis.');
|
|
// isValid = false;
|
|
// } else if (!validatePostal(value)) {
|
|
// $('#error_postal').text('Le code postal doit avoir 5 chiffres.');
|
|
// isValid = false;
|
|
// } else {
|
|
// $('#error_postal').text('');
|
|
// }
|
|
// }
|
|
|
|
// // Validation du téléphone
|
|
// if (id === 'telephone') {
|
|
// if (value === '') {
|
|
// $('#telephone-error').text('Le téléphone est requis.');
|
|
// isValid = false;
|
|
// } else if (!validatePhone(value)) {
|
|
// $('#telephone-error').text('Veuillez entrer un numéro de téléphone valide de 10 chiffres.');
|
|
// isValid = false;
|
|
// } else {
|
|
// $('#telephone-error').text('');
|
|
// }
|
|
// }
|
|
// });
|
|
|
|
// // Validation finale lors de l'envoi du formulaire
|
|
// $('#beneficiaryForm').on('submit', function(event) {
|
|
// let valid = true;
|
|
|
|
// $('#beneficiaryForm input, #beneficiaryForm select').each(function() {
|
|
// $(this).trigger('change'); // Déclencher la validation pour chaque champ
|
|
// if ($(this).next('.error').text() !== '') {
|
|
// valid = false;
|
|
// }
|
|
// });
|
|
|
|
// if (!valid) {
|
|
// event.preventDefault(); // Empêche l'envoi si des erreurs existent
|
|
// $.notify('Veuillez corriger les erreurs du formulaire.', 'error');
|
|
// }
|
|
// });
|
|
// });
|
|
|