0
現在、編集を終えた後に行を編集して保存できる表があります。電子メールセルに電子メールが含まれていない場合は保存しないなど、検証を追加できるようにしたいと考えています。私は保存をクリックしてフィールドが検証されていない場合、エラーを表示するダイアログボックスを表示したいと思います。これどうやってするの?ここで編集中の表内のセルの妥当性検査
は、私は必要なものである:
Buyer ID - numbers only
POC Name - text only
POC Email - email only
POC Phone - phone number only
相対Javascriptを:
$(document).ready(function() {
$('.edit').click(function() {
var $this = $(this);
var tds = $this.closest('tr').find('td').not('.mr_id').filter(function() {
return $(this).find('.edit').length === 0;
});
if ($this.html() === 'Edit') {
$this.html('Save');
tds.prop('contenteditable', true);
} else {
$this.html('Edit');
tds.prop('contenteditable', false);
}
});
});
相対HTML/PHP:
<?php
foreach ($dbh->query($sql) as $rows){
?>
<tr>
<td class="mr_id" contenteditable="false"><?php echo intval ($rows['MR_ID'])?></td>
<td class="mr_name" contenteditable="false"><?php echo $rows['MR_Name']?></td>
<td class="buyer_id" contenteditable="false"><?php echo $rows['Buyer_ID']?></td>
<td class="poc_n" contenteditable="false"><?php echo $rows['MR_POC_N']?></td>
<td class="poc_e" contenteditable="false"><?php echo $rows['MR_POC_E']?></td>
<td class="poc_p" contenteditable="false"><?php echo $rows['MR_POC_P']?></td>
<td><button class="edit" name="edit">Edit</button>
<button class="delRow" name="delete" onclick="deleteRow(this)">Delete</button></td>
</tr>
jQueryの輸入:
<head>
<title>Stage Rebate Master HTML Table</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="jquery-1.12.4.min.js"></script>
<link rel="stylesheet" type="text/css" href="html_master.css">
<script type="text/javascript" src="html_master.js"></script>
</head>
追加する必要がある場合を除き、私のコードではうまくいかないようです。 – Rataiczak24
に間違いをしてもらえますか? –
私はそれを実行し、テーブルが現れます...セルが空白または文字/単語があるようにバイヤーIDを編集すると、それでも私はそれを保存することができます – Rataiczak24