我正在尝试验证仅应接收文本且不包含数字的输入元素
这是输入字段
在此字段中,我只想接收文本,没有数字
HTML
<td>
<input type="text" id="name" name="name" class="form-control small">
</td>
<td>
<input type="text" id="age" name="age" class="form-control small">
</td>
jQuery
$(document).ready(function()
{
var validate = $('#form').validate({
ignore : ":not(:visible)",
debug : true,
rules: {
name: {
required : true,
required : isNaN() // I did this, didn't work
required : isNaN(this) // then this
},
age: {
required : true
},
messages: {
name: {
required : "Required",
required : "Cannot be number"
},
age: {
required : "Required"
},
onfocusout : false,
invalidHandler : function (form, validator)
{
var errors = validator.numberOfInvalids();
if (errors)
{
validator.errorList[0].element.focus();
}
}
}).form();
});
我该怎么做?
使用这种方法是否可以验证NaN?