Commit 08153b67 authored by adri's avatar adri
Browse files

datePatern & input change

parent a345a225
htmlAddUser = '<tr class="newRecord">\
<td class="login">\
<input type="text" /></td>\
<td class="datene">\
<td class="datene" placeholder="yyyy/mm/dd">\
<input type="date" /></td>\
<td class="email">\
<input type="text" /></td>\
......@@ -18,10 +18,13 @@ htmlAddUser = '<tr class="newRecord">\
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/
datePatern = /^\d{4}[\/\-](?:\d{1}|1[012]|0\d)[\/\-](?:\d{1}|[123]\d|0\d)/
$(function() {
$("#allRecord").on("keyup", ".pw input", function() {
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~INPUT EVENT~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
$("#allRecord").on("keyup change", ".pw input", function() {
if (passwordPatern.test($(this).val()) || $(this).val() == "") {
$(this).css("background-color", "");
$('div', $(this).parent()).css("display", "none");
......@@ -30,7 +33,7 @@ $(function() {
$('div', $(this).parent()).css("display", "block");
}
});
$("#allRecord").on("keyup", ".email input", function() {
$("#allRecord").on("keyup change", ".email input", function() {
if (mailPatern.test($(this).val())) {
$(this).css("background-color", "");
$('div', $(this).parent()).css("display", "none");
......@@ -39,6 +42,16 @@ $(function() {
$('div', $(this).parent()).css("display", "block");
}
});
$("#allRecord").on("keyup change", ".datene :input", function(e) {
console.log(e.target.value);
if (datePatern.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 DEL~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
......@@ -119,7 +132,7 @@ $(function() {
if (className == "pw")
inputOptions += 'type="password" data-oldpw="' + ltrim(j.html()) + '" ';
else if (j.attr('class') == "datene")
inputOptions += 'type="date" '
inputOptions += 'type="date" placeholder="yyyy/mm/dd"'
j.html('<input ' + inputOptions + ' value="' + (j.attr('class') == "pw" ? '' : ltrim(j.html())) + '" />');
if (className == "pw") {
j.append("<div>le mot de passe comporte entre 8 et 16 caractères parmi a..z A..Z 0..9</div>")
......@@ -137,7 +150,7 @@ $(function() {
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function callBackVerif(data) {
var dataToSend = new Object(); //Objet contenant les données à envoyé
dataToSend["updatePW"] = (data === true ? false : true);
dataToSend["updatePW"] = (data === true ? false : true); //Si maj du mdp data === false
if ($(".pw input", tr).val() === data || data === true) //Verif du mot de passe si nécesaire
{
for (i = 0; i < tds.length - 1; i++) //Analyse de chaque td
......@@ -218,9 +231,11 @@ $(function() {
});
});
//J'avais plein d'espace a droite en récupérent mon innerHTML
//J'avais plein d'espace à droite et à gauche 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, '');
str = str.replace(/^\s+/g, '')
str = str.replace(/\s+$/g, '')
return str;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment