Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery表单验证,表单输入的名称如下[]_Jquery_Html_Validation - Fatal编程技术网

jQuery表单验证,表单输入的名称如下[]

jQuery表单验证,表单输入的名称如下[],jquery,html,validation,Jquery,Html,Validation,是否可以使用jQuery来验证像这样的表单输入 <input type='text' name='amount[]' size='1' /> <input type='text' name='amount[]' size='1' /> <input type='text' name='amount[]' size='1' /> 或者有其他选择 找到解决方案-试试这个 <input type='text' name='amount[]' si

是否可以使用jQuery来验证像这样的表单输入

<input type='text' name='amount[]' size='1' />
<input type='text' name='amount[]' size='1' />
<input type='text' name='amount[]' size='1' />

或者有其他选择

找到解决方案-

试试这个

    <input type='text' name='amount[]' size='1' id="id1" />
    <input type='text' name='amount[]' size='1' id="id2"/>
    <input type='text' name='amount[]' size='1' id="id3"/>

并使用id进行验证

尝试:

​$("input[name='amount[]']").each(function(i, item){
    // Do your validation here..
    // You can use $(this) to refer to the element
});​​​​​​​​

在jquery中使用如下索引:

 $('input').eq(0).bind('change keyup',function(){ ... });
或对第二个输入框使用以下代码:

 $('input').eq(1).bind('change keyup',function(){ ... });
 $('input').eq(2).bind('change keyup',function(){ ... });
或者这一个用于第三个输入框:

 $('input').eq(1).bind('change keyup',function(){ ... });
 $('input').eq(2).bind('change keyup',function(){ ... });

如果jQuery插件没有处理这些问题,我真的会感到惊讶,所以可能值得一试。这种命名方式应该保留给单选按钮组。你想做什么?我想用这样的名字做一个购物车,因为每次都有不同数量的输入,每个项目1个输入。@JayBlanchard-不,不应该。事实上,这种命名方式对无线组没有用处,因为一个组中只能检查一个元素(而
[]
语法的要点是让PHP将数据表示为数组,而不是将除了一个值以外的所有数据都放在地板上)。@user1093555-jQuery没有内置的验证功能。你有什么理由认为你不能用jQuery编写JavaScript来验证HTML吗?Sry我是jQuery新手,我能用它多方便?现在我得到了这个代码
code
$(document).ready(function(){$(“#cartform”).validate({errorPlacement:function(error,element){error.appendTo(element.next();}}}});你看过报纸了吗?你不明白的是什么?这个插件非常适用于具有唯一名称的普通输入,但我需要使用类似于[]的名称验证输入,我一直有不同数量的表单输入。你看过ManseUK的答案吗?