Daripada mengabaikan, lebih baik kita membuat sendiri yuk
Include-kan Jquery pada halaman script.
Contoh include jquery jika ada di folder web
<script type="text/javascript" src="jquery-1.9.0.js"/></script>
Contoh include jquery menggunakan cdn
Lalu buatlah script ajax :<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>Buatlah beberapa tag html untuk eksekusi ajax
$(document).ready(function() {
$('#pass').keyup(function(e) {
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
var enoughRegex = new RegExp("(?=.{6,}).*", "g");
if (false === enoughRegex.test($(this).val())) {
$('#passstrength').addClass( "label label-important" );
$('#passstrength').html('Lemah Sekali');
} else if (strongRegex.test($(this).val())) {
$('#passstrength').addClass( "label label-success" );
$('#passstrength').html('Wow!');
} else if (mediumRegex.test($(this).val())) {
$('#passstrength').addClass( "label label-warning" );
$('#passstrength').html('Lumayan!');
} else {
$('#passstrength').addClass( "label label-important" );
$('#passstrength').html('Lemah!');
}
return true;
});
});
</script>
<input type="password" name="pass" id="pass" /><br>Keterangan :
<span id="passstrength"></span>
Menggunakan CSS bootstrap
0 Response to "JQuery Cek Kekuatan Password"
Posting Komentar