jEditable で 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>
これは、私が使用している 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',
});
});
ここで、jEditable は完全に機能しています。しかし、検証は機能していません。この検証コードは正しいですか?