我正在尝试添加下面的表单rulset-范围1至5。
收到以下错误:
'意外令牌['
范围是一个数组,因此我并不是真正了解此错误。
$(document).ready(function(){
$(".formValidation").validate({
rules:{
numberRange:{
required:true,
range[1,5]
}
}
});
});
<form class = "formValidation">
<fieldset>
<legend>Personal information:</legend>
<p>First name: </p>
<input type="text" name ="firstName" placeholder = "First name: ">
<p>Last name: </p>
<input type="text" name = "lastName" placeholder = "Last name: ">
<p>A number between 1-5: </p>
<input type="number" name = "numberRange" placeholder = "Number 1-5: " required>
<br>
<br>
<input type="submit" value = "Submit">
</fieldset>
</form>
预期的 :
定义范围应该像
$(".formValidation").validate({
rules:{
numberRange:{
required:true,
range:[1,5]
}
}
});