私は動的にテーブルを作成しており、動的に作成された日付テキストボックスでkeypressイベントをキャプチャしたいと考えています。私がpayment_date textkboxを1つしか持っていないのならそれは素晴らしいですが、私はたくさん持っています。私は.liveを見てきましたが、これを理解するにはあまりにも新しいです。誰かが私のために具体的なことができますか?ここで問題になっているテキストボックスとHTMLは次のとおりです。動的に作成されたテキストボックスのjQuery keypressイベント
<?php
foreach($student_classes as $class):
if($student['student_id'] == $class['student_id']) {
$i = $class['registration_id'];
$deleted = FALSE;
?>
<td>
<input type="text"
name="students[<?php echo $i ?>][registration_payment_date]"
id="payment_date[<?php echo $i ?>]"
value="<?= html($class['registration_payment_date']) ?>"
size='10' maxlength="10"
>
</td>
<?php endforeach; ?>
のjQuery:
jQuery(document).ready(function()
{
var $payment_date = jQuery('#payment_date');
// Format the date as it is entered
$payment_date.keypress(function(event) {
DateFormat(this, this.value, event, false, '1');
});
// Check to make sure the date is valid
$payment_date.change(function()
{
if(dateValid(this.value) == false);
alert('The date is not valid');
});
});
ありがとうございました! jQuery.live()
は動作しますが
ありがとうございます。私はそれを複雑にしていました - 本当に使用するのはとても簡単です。私はそれをもう一度読むので、私はそれを理解することができます。 – Sara