小编Jas*_*son的帖子

jquery min 和 maxlength 验证

我想要minlength=8maxlength=14,我怎样才能实现这个验证。

html:

<input type="text" name="354" id="field">
Run Code Online (Sandbox Code Playgroud)

jQuery:

$("input[name=354]").keypress(function(e){
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
$("#errmsg").html("Digits only").show().fadeOut("slow");
return false;
}
});
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

6
推荐指数
2
解决办法
2万
查看次数

标签 统计

html ×1

javascript ×1

jquery ×1