我查看了其他一些问题,但无法获得他们的解决方案。我在DataTables中使用以下代码来验证jEditable字段:
$('#example tbody .samples').editable( 'jeditable_ajax.php', {
submitdata: function ( value, settings ) {
return {
row_id: oTable.fnGetData(oTable.fnGetPosition(this)[0],0),
column: oTable.fnGetPosition(this)[2]
};
},
onsubmit: function(settings, td){
console.log($(this));
console.log($(this).find('input').attr('name'));
$(this).validate({
debug: true,
rules: {
value: {
required: true,
number: true
}
},
messages: {
value: "Error"
},
errorClass: "invalid",
submitHandler: function() {
alert("Success!");
}
});
return ($(this).valid());
},
onblur: "submit",
placeholder: " ",
tooltip: "Click to edit"
} );
我没有从jQuery Validation中获得任何调试错误(带有debug: true
on),并且jEditable字段似乎自动具有值的名称(即:<input type="text" name="value"/>
,我已通过确认)console.log($(this).find('input').attr('name'));
。
在errorClass
不施加与用于非数字数据中没有错误消息。
出于某种原因,即使我复制/粘贴了上面的代码块,代码现在仍然可以工作,而以前却不在……我不知道为什么。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句