2021-03-15 13:03:29 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
var Validation = function() {
|
|
|
|
// Set password variables
|
|
|
|
var pass1 = $('#pass1').val();
|
|
|
|
var pass2 = $('#pass2').val();
|
|
|
|
|
2021-03-25 08:30:04 +00:00
|
|
|
var minLen = false;
|
|
|
|
var maxLen = false;
|
2021-03-15 13:03:29 +00:00
|
|
|
var le = false;
|
|
|
|
var cle = false;
|
2021-03-25 08:30:04 +00:00
|
|
|
var spc = false;
|
2021-03-15 13:03:29 +00:00
|
|
|
var num = false;
|
|
|
|
|
|
|
|
// Length Validation.
|
|
|
|
if (pass1.length < 8)
|
|
|
|
{
|
2021-03-25 08:30:04 +00:00
|
|
|
$('#min-length').removeClass('valid').addClass('invalid');
|
|
|
|
minLen = false;
|
2021-03-15 13:03:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-03-25 08:30:04 +00:00
|
|
|
$('#min-length').removeClass('invalid').addClass('valid');
|
|
|
|
minLen = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Max length validation
|
|
|
|
if (pass1.length > 255)
|
|
|
|
{
|
|
|
|
$('#max-length').removeClass('valid').addClass('invalid');
|
|
|
|
maxLen = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('#max-length').removeClass('invalid').addClass('valid');
|
|
|
|
maxLen = true;
|
2021-03-15 13:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Letter Validation
|
|
|
|
if (pass1.match(/[A-z]/))
|
|
|
|
{
|
|
|
|
$('#letter').removeClass('invalid').addClass('valid');
|
|
|
|
le = true
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('#letter').removeClass('valid').addClass('invalid');
|
|
|
|
le = false
|
|
|
|
}
|
|
|
|
|
|
|
|
// Capital Letter Validation
|
|
|
|
if (pass1.match(/[A-Z]/))
|
|
|
|
{
|
|
|
|
$('#capital').removeClass('invalid').addClass('valid');
|
|
|
|
cle = true
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('#capital').removeClass('valid').addClass('invalid');
|
|
|
|
cle = false
|
|
|
|
}
|
|
|
|
|
2021-03-25 08:30:04 +00:00
|
|
|
// Special character validation
|
|
|
|
if (pass1.match(/[!@#$%^&*(),.?":{}|<>]/))
|
|
|
|
{
|
|
|
|
$('#special').removeClass('invalid').addClass('valid');
|
|
|
|
spc = true
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('#special').removeClass('valid').addClass('invalid');
|
|
|
|
spc = false
|
|
|
|
}
|
|
|
|
|
2021-03-15 13:03:29 +00:00
|
|
|
// Number Validation
|
|
|
|
if (pass1.match(/\d/))
|
|
|
|
{
|
|
|
|
$('#number').removeClass('invalid').addClass('valid');
|
|
|
|
num = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('#number').removeClass('valid').addClass('invalid');
|
|
|
|
num = false;
|
|
|
|
}
|
|
|
|
|
2021-03-25 08:30:04 +00:00
|
|
|
if (minLen && maxLen && le && cle && spc && num)
|
2021-03-15 13:03:29 +00:00
|
|
|
{
|
|
|
|
$('#pass_info').hide();
|
|
|
|
$('#pass1, #pass2').removeClass('invalidInput').addClass('validInput');
|
|
|
|
|
|
|
|
if (pass1 === pass2)
|
|
|
|
{
|
|
|
|
$('#pass2').removeClass('invalidInput').addClass('validInput');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('#pass2').removeClass('validInput').addClass('invalidInput');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('#pass_info').show();
|
|
|
|
|
|
|
|
$('#pass1, #pass2').removeClass('validInput').addClass('invalidInput').focus(function() {
|
|
|
|
$('#pass_info').show();
|
|
|
|
}).blur(function() {
|
|
|
|
$('#pass_info').hide();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#pass1, #pass2').click(function() {
|
|
|
|
Validation();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#pass1, #pass2').keyup(function() {
|
|
|
|
Validation();
|
|
|
|
});
|
|
|
|
});
|