diff --git a/public_html/view/js/users.js b/public_html/view/js/users.js index 5c2dd84..bd2729f 100755 --- a/public_html/view/js/users.js +++ b/public_html/view/js/users.js @@ -310,7 +310,16 @@ if( section.create.element != null ){ mail: document.querySelector(section.create.text + '#create_mail'), submit: document.querySelector(section.create.text + '#create_submit') - } + }; + + // On recupere tous les messages d'erreur + section.create.errmsg = { + code: document.querySelector(section.create.text + '.error-msg.create_code'), + username: document.querySelector(section.create.text + '.error-msg.create_username'), + firstname: document.querySelector(section.create.text + '.error-msg.create_firstname'), + lastname: document.querySelector(section.create.text + '.error-msg.create_lastname'), + mail: document.querySelector(section.create.text + '.error-msg.create_mail') + }; // On initialise le gestionnaire des saisies var createChecker = new inputChecker(); @@ -331,6 +340,12 @@ if( section.create.element != null ){ // On annule l'envoi de base (PHP) e.preventDefault(); + section.create.errmsg.code.innerHTML = + section.create.errmsg.username.innerHTML = + section.create.errmsg.firstname.innerHTML = + section.create.errmsg.lastname.innerHTML = + section.create.errmsg.mail.innerHTML = ''; + var request = { path: 'userDefault/create', // On veut creer un utilisateur code: section.create.input.code.value, @@ -353,8 +368,11 @@ if( section.create.element != null ){ section.create.input.lastname.value = ''; section.create.input.mail.value = ''; - }else // Erreur + }else{ // Erreur console.error('ModuleError::'+answer.error); + if( /^[^']*'(\w+)'/i.test(answer.ErrorDescription) ) + section.create.errmsg[RegExp.$1].innerHTML = 'Champ manquant ou erronné.'; + } });