如何检查$dateStart
和$dateEnd
是否为空?
<?php
if (isset($_POST['submit'])) {
$leaveR = $_POST['leave'];
$dateStart = $_POST['startDate'];
$dateEnd = $_POST['endDate'];
$leaveReason = $_POST['reason'];
$credits = $_POST['credit'];
$oic = $_POST['oicc'];
if ($leaveR == "" || $dateStart == "" || $dateEnd == "" || $leaveReason == "" ||
$credits == "" || $oic == "") {
echo '<div class="alert alert-danger" role="alert">Fill up all fields</div>';
答案 0 :(得分:0)
这部分取决于您的JavaScript代码。 datepicker是默认设置为当前日期还是&#34; 0000-00-00&#34;例如。或者它只是返回空白。
不知道你的javascript启动datepicker的综合答案:
if( isset( $_POST['startDate'] ) && trim( $_POST['startDate'] ) !== "" && trim( $_POST['startDate'] ) !== "0000-00-00" || !isset( $_POST['startDate'] ) ) {
// do something
}