40 lines
939 B
JavaScript
40 lines
939 B
JavaScript
|
var crPrenom = document.getElementById('crPrenom');
|
||
|
var crNom = document.getElementById('crNom');
|
||
|
|
||
|
|
||
|
|
||
|
/* VERIFICATION DES SAISIES */
|
||
|
|
||
|
////////////
|
||
|
// PRENOM //
|
||
|
////////////
|
||
|
crPrenom.addEventListener('keyup', function(e){
|
||
|
if( /^([a-z]{3,45})$/i.test(crPrenom.value) ){ // si champ correct
|
||
|
addClass(crPrenom, 'validated');
|
||
|
remClass(crPrenom, 'invalid');
|
||
|
}else{
|
||
|
remClass(crPrenom, 'validated');
|
||
|
|
||
|
if( crPrenom.value.length <= 4 || crPrenom.value.length > 45 )
|
||
|
addClass(crPrenom, 'invalid');
|
||
|
else
|
||
|
remClass(crPrenom, 'invalid');
|
||
|
}
|
||
|
}, false);
|
||
|
|
||
|
/////////
|
||
|
// NOM //
|
||
|
/////////
|
||
|
crNom.addEventListener('keyup', function(e){
|
||
|
if( /^([a-z]{3,45})$/i.test(crNom.value) ){ // si champ correct
|
||
|
addClass(crNom, 'validated');
|
||
|
remClass(crNom, 'invalid');
|
||
|
}else{
|
||
|
remClass(crNom, 'validated');
|
||
|
|
||
|
if( crNom.value.length <= 4 || crNom.value.length > 45 )
|
||
|
addClass(crNom, 'invalid');
|
||
|
else
|
||
|
remClass(crNom, 'invalid');
|
||
|
}
|
||
|
}, false);
|