我有以下的HTML表單:如何檢查輸入型日期爲空或不使用JavaScript或jQuery的
<form id="ChartsForm">
<div id="dateoptions">
<p>Until date: <input type="date" name="until_date" value="Until date"></p>
<p>Since date: <input type="date" name="since_date" value="Since date"></p>
</div>
<div class="insightsoptions">
<input id="newLikes" class="insightsbuttons" type="submit" name="submit" value="Daily new likes">
<input id="unlikes" class="insightsbuttons" type="submit" name="submit" value="Daily unlikes">
</div>
</form>
和下面的jQuery腳本:
$(function() {
$("#newLikes").one('click', function() {
$.ajax({type:'GET', url: 'newLikes.php', data:$('#ChartsForm').serialize(), success:
function(response) {
alert(response);
$("#dailyNewLikes").html(response);
}});
return false;
});
$("#newLikes").on('click', function(){
$(this).toggleClass('green');
$('#dailyNewLikes').toggle();
});
如何檢查輸入「until_date」和「since_date」是空的或不在第一位,如果它們是空的以在執行ajax調用之前停止腳本,則提醒用戶關於錯誤,然後在輸入不再爲空時繼續。我必須使用.one()
。我試過了。 blur()
功能,但不起作用...