$(function() {
passwordPatern=/^[a-zA-Z0-9]{8,16}$/;
loginPatern=/^[a-z]{8,16}$/
mailPatern=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;//https://emailregex.com/
$("#allRecord").on("keyup", ".pw input", function(){
if(passwordPatern.test($(this).val()) || $(this).val() == "")
{
$(this).css("background-color", "");
$('div', $(this).parent()).css("display", "none");
}
else
{
$(this).css("background-color", "red");
$('div', $(this).parent()).css("display", "block");
}
});
$("#allRecord").on("keyup", ".email input", function(){
if(mailPatern.test($(this).val()))
{
$(this).css("background-color", "");
$('div', $(this).parent()).css("display", "none");
}
else
{
$(this).css("background-color", "red");
$('div', $(this).parent()).css("display", "block");
}
});
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~TR TO EDIT~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
$("#allRecord").on("click", ".editUser", function() {
$(this).toggleClass('fa-edit fa-check');
$(this).toggleClass('editUser confirmEditUser');
for(i=1; i<$("td", $(this).parent().parent()).length-1;i++)
{
j= $($("td", $(this).parent().parent())[i]);
className = j.attr('class');
if(className == "sl")
{
val = ltrim(j.html());
j.html('')
}
else
{
inputOptions = '';
if(className=="pw")
inputOptions += 'type="password" data-oldpw="'+ltrim(j.html())+'" ';
else if (j.attr('class') == "datene")
inputOptions += 'type="date" '
j.html('');
if(className=="pw")
{
j.append("
le mot de passe comporte entre 8 et 16 caractères parmi a..z A..Z 0..9
")
}
}
}
});
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~CONFIRM EDIT~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
$("#allRecord").on("click", ".confirmEditUser", function() {
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~CALL BACK DE LA VERIF DE MOT DE PASSE~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function callBackVerif(data){
var dataToSend = new Object(); //Objet contenant les données à envoyé
dataToSend["updatePW"] = (data===true?false:true);
if($(".pw input", tr).val() === data || data === true) //Verif du mot de passe si nécesaire
{
for(i=0; i"+e , "error" );
}
console.log(data.return)
}, "json");
}
else {
swal( "Oops" , "Password don't match !" , "error" );
}
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
tds = $("td", $(this).parent().parent()); //Récupère les td concernant le click
tr = $(this).parent().parent(); //Récupère le tr concernant le click
that = this;
if(mailPatern.test($(".email input", tr).val()) && (passwordPatern.test($(".pw input", tr).val()) || $(".pw input", tr).val() ==""))
if ($(".pw input", tr).val() === "") {
callBackVerif(true);
}
else {
swal({
closeOnClickOutside: false,
closeOnEsc: false,
content: {
element: "input",
attributes: {
placeholder: "Confirmer le mot de passe",
type: "password",
},
},
}).then(callBackVerif);
}
else
swal( "Oops" , "Input don't respect rules !" , "error" );
});
});
//J'avais plein d'espace a droite en récupérent mon innerHTML
//https://stackoverflow.com/questions/24282158/removing-the-white-space-at-the-start-of-the-string
function ltrim(str) {
if(str == null) return str;
return str.replace(/^\s+/g, '');
}