Jquery 表验证不起作用
我想对表使用jQuery验证。在这里,我在一个类似这样的while循环中回显数据库中的一个表Jquery 表验证不起作用,jquery,jquery-validate,jeditable,edit-in-place,Jquery,Jquery Validate,Jeditable,Edit In Place,我想对表使用jQuery验证。在这里,我在一个类似这样的while循环中回显数据库中的一个表 <table id="example" class="display" cellspacing="0" border="0"> <thead> <tr> <th> Name </th> <th> Phone </th> </tr> </thead&
<table id="example" class="display" cellspacing="0" border="0">
<thead>
<tr>
<th>
Name
</th>
<th>
Phone
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="items" userid="'.$row['id'].'" id="name">'.$row['name'].'</td>
<td class="items required" userid="'.$row['id'].'" id="phone">'.$row['phone'].'</td>
</tr>
</tbody>
</table>
名称
电话
“.$row['name']”
“.$row['phone']”
这是我使用的带有jQuery验证代码的jEditable脚本
$("td.items").each(function(index) {
$(this).editable("handler.php", {
onsubmit: function(settings, td) {
var input = $(td).find('input');
$(this).validate({
rules: {
phone: {
number: true,
}
},
messages: {
phone: {
number: 'Only numbers are allowed',
}
},
});
return ($(this).valid());
},
submitdata : {userid: $(this).attr('retailerid')},
indicator : "<img src='images/indicator.gif'>",
tooltip : "Doubleclick to edit...",
event : "dblclick",
onblur : "submit",
name : 'newvalue',
id : 'elementid',
});
});
$(“td.items”)。每个(函数(索引){
$(this).editable(“handler.php”,{
onsubmit:功能(设置,td){
var input=$(td.find('input');
$(此)。验证({
规则:{
电话:{
数字:对,
}
},
信息:{
电话:{
数字:“只允许数字”,
}
},
});
返回($(this.valid());
},
submitdata:{userid:$(this.attr('retailerid')},
指标:“,
工具提示:“双击以编辑…”,
事件:“dblclick”,
onblur:“提交”,
名称:“newvalue”,
id:'elementid',
});
});
在这里,这张桌子工作得很好。但验证工作并没有起作用。此验证代码正确吗
引用OP:“此验证代码正确吗?”
事实并非如此。插件参数中目标的输入
元素的名称应仅引用表单
中输入
元素的名称
属性,而不是表
中单元格的id
这样,设计的目标仅针对
中包含的
元素。您的代码中既没有也没有
Sparky672-那么如何使用该表进行验证?请帮忙:)@collozziza,这不是你最初问的。。。我只知道,除非在
表单
元素中有输入
元素,否则无法使用验证插件。也许你需要发布一个关于如何正确使用jEditable进行验证的新问题。Sparky672-这就是我要问的:)如何使用jEditable进行验证。这是我的密码。jEditable在单击或dblclick right时创建一个input
元素?@collozziza,我已经回答了您最初的问题。所以现在我是说,你们应该发布一个全新的问题,让熟悉绝地表的人可以回答。请记住,我们不是在这里从头开始构建您的整个项目。