我想要minlength=8和maxlength=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)