1 // Initialize form validation on the registration form. 2 // It has the name attribute "registration" 3 4 5$.validator.addMethod( 6 "regex", 7 function(value, element, regexp) { 8 if (regexp.constructor != RegExp) 9 regexp = new RegExp(regexp); 10 else if (regexp.global) 11 regexp.lastIndex = 0; 12 return this.optional(element) || regexp.test(value); 13 },"erreur expression reguliere" 14); 15 16 $("form[name='contact']").validate({ 17 // Specify validation rules 18 rules: { 19 // The key name on the left side is the name attribute 20 // of an input field. Validation rules are defined 21 // on the right side 22 23 nom: requiredNom, 24 prenom: requiredPrenom, 25 civilite: requiredCivilite, 26 societe: requiredSociete, 27 telephone: { 28 required: requiredTelephone, 29 "regex": /^(\+33|0)[0-9]{9}$/ 30 }, 31 adresse: requiredAdresse, 32 codePostal: requiredCodePostal, 33 ville: requiredVille, 34 message: requiredMessage, 35 champ1: requiredChamp1, 36 champ2: requiredChamp2, 37 champ3: requiredChamp3, 38 champ4: requiredChamp4, 39 champ5: requiredChamp5, 40 champ6: requiredChamp6, 41 champ7: requiredChamp7, 42 email: { 43 required: requiredemail, 44 email: true 45 }, 46 'rgpd': { 47 required: requiredRGPD 48 } 49 50 }, 51 // Specify validation error messages 52 messages: { 53 nom: erreurNom, 54 prenom: erreurPrenom, 55 civilite: erreurCivilite, 56 societe: erreurSociete, 57 telephone: erreurTelephone, 58 adresse: erreurAdresse, 59 codePostal: erreurCodePostal, 60 ville: erreurVille, 61 message: erreurMessage, 62 champ1: erreurChamp1, 63 champ2: erreurChamp2, 64 champ3: erreurChamp3, 65 champ4: erreurChamp4, 66 champ5: erreurChamp5, 67 champ6: erreurChamp6, 68 champ7: erreurChamp7, 69 email: erreurEmail, 70 rgpd: erreurRGPD 71 }, 72 // Make sure the form is submitted to the destination defined 73 // in the "action" attribute of the form when valid 74 submitHandler: function(form) { 75 $('#submit').val("Envoi en cours"); 76 $('body').addClass('envoiencours'); 77 form.submit(); 78 } 79 }); 80// JavaScript Document
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.