onkeydown イベントに問題があります。2 つの入力要素で使用していますが、最初の要素でしか機能しません。2番目に、それは私にエラーを与えるだけです: Uncaught TypeError: object is not a function
.
jQuery:
function count() {
var length = $('#pass').length;
if (length < 32) {
$('#length').text(length + ' characters out of 32');
}
}
function match() {
if ($('#pass').attr('value') == $('#pass2').attr('value'))
{
$('#match').text('<img src="/css/images/check.png" /> Passwords match.');
}
else
{
$('#match').text('<img src="/css/images/close.png" /> Passwords do not match.');
}
}
HTML:
<form method='post'>
<input type='password' name='pass' value='' id='pass' onkeydown='count()' />
<span id='length'></span>
<input type='password' name='pass2' value='' id='pass2' onkeydown='match()' />
<span id='match'></span>
</form>