Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.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_Jquery Validate_Jeditable_Edit In Place - Fatal编程技术网

Jquery 表验证不起作用

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&

我想对表使用jQuery验证。在这里,我在一个类似这样的while循环中回显数据库中的一个表

<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,我已经回答了您最初的问题。所以现在我是说,你们应该发布一个全新的问题,让熟悉绝地表的人可以回答。请记住,我们不是在这里从头开始构建您的整个项目。