$(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 DEL~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ $("#allRecord").on("click", ".delUser", function() { tr = $(this).parent().parent(); var login = ""; var sl = ""; if(tr.find("i.editUser").length !== 0) { sl = ltrim($('.sl', tr).html()) login = $('.login', tr).html(); } else if(tr.find("i.confirmEditUser").length !== 0) { sl = $('.sl select', tr).val(); login = $('.login', tr).html(); } else { swal("error"); return ; } console.log(sl); if(sl == "10") { swal( "Oops" , "You can't del user with sl 10" , "error" ); return; } login = ltrim(login); swal({ title: "Are you sure to del "+login+" ?", text: "Once deleted, you will not be able to recover this!", icon: "warning", buttons: true, dangerMode: true, }) .then((willDelete) => { if (willDelete) { $.post("post.php", {userToDel: login}, function(){ tr.remove(); swal("Poof! "+login+" has been deleted!", { icon: "success", }); }) } else { } }); }); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~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("