1
我试图写一些验证来检查并查看一个字段是否大于某个长度,如果它是抛出一个错误。我似乎无法让它工作,但当我搜索某些东西时,通常需要使用.val()路径进行验证。jquery如果值大于某个长度
所以我
$('.btn-danger').on('click', function(){
if ($('input[name="spine_text"]').length > 22) {
$('.spineError').html('This field must only have 22 characters.');
$('.spineError').addClass('marginBottom');
$('html, body').animate({
scrollTop: ($('.cloth').first().offset().top)
},500);
$('.clothError').html('');
return false;
}
});
,我已经试过.length() > 22
为好。它们都不工作。
一个的jsfiddle发挥与http://jsfiddle.net/PE6rD/
这使得焚香!非常感谢,我知道我忘记了一些愚蠢的东西! – zazvorniki