我在這裏有一個演示: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