Vib*_*bhs 1 javascript passwords jquery
我想检查密码长度是否至少为8个字符,当用户离开密码字段或按Tab键时.我怎样才能做到这一点?
我的密码代码如下所示.
<input type="password" name="password" id="pass1" placeholder="password"/>
Run Code Online (Sandbox Code Playgroud)
blur为此使用jquery 方法.
$('#pass1').on('blur', function(){
if(this.value.length < 8){ // checks the password value length
alert('You have entered less than 8 characters for password');
$(this).focus(); // focuses the current field.
return false; // stops the execution.
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16939 次 |
| 最近记录: |