JQuery Keydown, Keypress and Keyup Event
JQuery Keydown, Keypress and Keyup Event
HTML
<h1>
Password validation
</h1>
<input id="txtInput" type="text" />
<span id="msg"></span>
JavaScript
$(document).ready(function () {
var regex = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$_ (){*}+-.&/\\,;|"'=\[\]^`~])[0-9a-zA-Z!@#$_ (){*}+-.&/\\,;"|'=\[\]^`~]{6,10}$/;
$("#txtInput").keyup(
function (event) {
$('#msg').text(regex.test($('#txtInput').val())+" Length: " + $('#txtInput').val().length);
}
);
});