[英]how to disable before today date and time 9.00am-9.00pm using AngularJS?
我有兩個字段,一個是日期,另一個是時間。在這里,用戶可以選擇從今天的日期到一個月期間的日期(如何避免選擇一個月或今天之前的日期)。第二個字段的時間選擇器我需要驗證,只有用戶可以選擇上午9:00至下午9:00。
<div class="row"> <div class="col"> <label class="item item-input item-stacked-label"> <span class="input-label">Date</span> <input type="date" ng-model="bookdate" name="bookdate" > </label> </div> <div class="col"> <label class="item item-input item-stacked-label"> <span class="input-label" >Time</span> <input type="time" ng-model="booktime" name="booktime"> </label> </div> </div>
Angular的輸入時間指令支持以24小時格式設置最小值和最大值。
<input type="time"
ng-model="booktime"
name="booktime"
min="09:00:00"
max="21:00:00">
請檢查以下詳細信息,並提供有關input[date]
和input[time]
。
對於日期: 輸入[日期] :
詳細參數:min(可選)字符串-如果輸入的值小於min,則設置min驗證錯誤鍵。 這必須是有效的ISO日期字符串(yyyy-MM-dd)。
視圖:
<label class="item item-input item-stacked-label">
<span class="input-label">Date</span>
<input type="date" ng-model="bookdate" name="bookdate" max="{{bookdate | bookdate:'yyyy-MM-dd'}}" max="{today}">
</label>
到目前為止,修改您的控制器:
var today=new Date();
$scope.today = today.toISOString();
對於時間: input [time] :
視圖:
<label class="item item-input item-stacked-label">
<span class="input-label" >Time</span>
<input type="time" ng-model="booktime" name="booktime" min="09:00:00" max="21:00:00">
</label>
希望這對您有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.