【发布时间】:2014-05-25 23:31:05
【问题描述】:
在我的 html 表单中,除复选框值外,所有数据均已成功验证。它不适用于 jquery/ajax 请求。
这是我的 html 表单 ajax 和 html 代码(仅术语部分):
<tr>
<td>Terms & Conditions</td>
<td><input type="checkbox" name="terms"/> I agree to your <a href="">terms and
conditions</a>.</td>
<script>
$('#form1').submit(function(event) {
event.preventDefault();
$.ajax({
type: 'POST',
url: 'regProcess.php',
data: $(this).serialize(),
dataType: 'json',
success: function (data) {
$('#info1').html('');
$.each( data, function( key, value ) {
$('#info1').append('<p>'+value+'</p>');
});
}
});
});
</script>
在 regProcess.php 页面下面是我的 Checkbox 验证代码,但它没有验证..
if(isset($_POST['terms']) && $_POST['terms'] == ""){
$msg[] = "You must agree our terms and conditions";
$msg1['error'] = true;
}
【问题讨论】: