如果文本字段为空,我需要创建jQuery验证表单然后出现警告。
这是我的代码:
<form action="" method="POST">
<input type="checkbox" name="dropshiper_ceck" id="id_dropshiper_ceck">
<label><b><?php echo $text_dropship; ?></b></label>
<div class="" id="id_dropshiper_form" name="dropshiper_form">
<hr/>
<p>
<?php echo $text_dropship_name; ?>
</p>
<input type="text" name="nama_dropshiper" style="width: 97%" placeholder="<?php echo $text_add_name_dropshiper; ?>" id="id_nama_dropshiper" value="">
<br/>
<br/>
<p>
<?php echo $text_dropship_telp; ?>
</p>
<input type="text" name="nomor_telp" style="width: 97%" placeholder="<?php echo $text_add_number_phone_dropshiper; ?>" id="id_nomor_telepon_dropshiper" value="">
</div>
</form>
答案 0 :(得分:0)
$('#id_dropshiper_ceck').change(function(){
// Check the textbox when the checkbox is checked
if ($('#id_dropshiper_ceck').prop('checked') == true){
if ($('#id_nama_dropshiper').val() == ""){
// alert message
alert('Warning Message');
}
if ($('#id_nomor_telepon_dropshiper').val() == ""){
// alert message
alert('Warning Message');
}
}
})
我想你想在单击复选框时检查文本框。