менее 8 символов, наличие заглавных, прописных букв, цифр, спецсимволов !#$%&()*+./:;=>?@[\]^`{|}~'
$(document).ready(function(){ $('#changePasswd').on('click',function(){ $('#changePasswdErrors').html(''); $('#changePasswdErrors').hide(); let passwd = $('#passwd').val(); let confPasswd = $('#confirm_passwd').val(); let errors = []; if(passwd != confPasswd){ errors.push("Password and password confirmation do not match"); } else{ if(passwd.length<8) { errors.push("Password length must be at least 8 characters"); } if(passwd === passwd.toLowerCase()){ errors.push("Password must contain uppercase characters"); } if(passwd === passwd.toUpperCase()){ errors.push("Password must contain lowercase characters"); } if(!passwd.match(/(\d+)/g)){ errors.push("Password must contain digits"); } //!#$%&()*+./:;=>?@[\]^`{|}~'\ let cpec = '!#$%&()*+./:;=>?@[]^`{|}~'+"'"; let b = false; let s = ''; for (let i = 0; i < cpec.length; i++) { s = cpec[i]; if(passwd.indexOf(s)!==-1){ b = true; break; } } if(!b){ errors.push("Password must contain special character "+'!#$%&()*+./:;=>?@[]^`{|}~'+"'"); } if(errors.length == 0){ $('#changePasswdForm').trigger('submit'); } else{ $('#changePasswdErrors').html(errors.join('<br>')); $('#changePasswdErrors').show(); } } }); }); |