我在这里有一个演示:http://hane-content.com/datepick/如何在php验证脚本中捕获jquery datepicker输入?
我有两个字段,名称和日期。 Jquery Datepicker附加到日期字段。我可以填写姓名字段,选择一个随机日期,然后点击提交。但是,当表单数据通过email.php处理时,会返回一个错误,说明日期尚未填写,例如日期字段为空。我是初学者。
你如何解决这个问题?
email.php
<?php
// email.php
$errors = array(); // array to hold validation errors
$data = array(); // array to pass back data
if (empty($_POST['datoa']))
$errors['dateoa'] = 'Date is required.';
if (empty($_POST['name']))
$errors['name'] = 'Name is required.';
// return a response ===========================================================
// if there are any errors in our errors array, return a success boolean of false
if (! empty($errors)) {
// if there are items in our errors array, return those errors
$data['success'] = false;
$data['errors'] = $errors;
} else {
// if there are no errors process our form, then return a message
// DO ALL YOUR FORM PROCESSING HERE
// THIS CAN BE WHATEVER YOU WANT TO DO (LOGIN, SAVE, UPDATE, WHATEVER)
// show a message of success and provide a true success variable
$data['success'] = true;
$data['message'] = 'Success!';
}
// return all our data to an AJAX call
echo json_encode($data);
?>
**错字** - '我会让你找到它 – 2015-02-24 20:07:56