我正在使用以下jQuery验证插件:
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
我正在尝试验证另一个数组中的嵌套数组“tax_percents []”。它只验证数组中的第一个值。奇怪的是,对于数组中的第二个字段,它会验证它并在字段1中给出错误消息。
这是一个显示错误的实时演示:
http://blastohosting.com/jquery_validate_array_error/
我有以下文件:
<!DOCTYPE html>
<html>
<head>
<script src="jquery.min.js"></script>
<script src="jquery.validate.js"></script>
</head>
<body>
<form action="" method="post" id="theForm">
Location 1 Tax 1:
<input type="text" name="locations[1][tax_percents][]" />
<br /><br />
Location 1 Tax 1:
<input type="text" name="locations[1][tax_percents][]" />
<br /><br />
Location 2 Tax 2:
<input type="text" name="locations[2][tax_percents][]" />
<br /><br />
Location 2 Tax 2:
<input type="text" name="locations[2][tax_percents][]" />
<input type="submit" />
</form>
<script>
$("#theForm").validate({
rules:
{
"locations[1][tax_percents][]":
{
number: true
},
"locations[2][tax_percents][]":
{
number: true
}
}
});
</script>
</body>
</html>
我做错了什么?
答案 0 :(得分:0)
该库不支持命名相同的功能并验证每个输入。