2017-04-11 73 views
-2

如何將日期範圍選取器輸入控件的自定義驗證("daterangerequired")添加到方法$.validator.addMethod()爲日期選擇器添加自定義驗證

<div class="input-daterange input-group" autoclose="True" data-calendarWeeks="True" clearBtn="True" defaultSecoundDateStartFrom="10" endDate="4/11/2019 3:30:40 PM" format="mm/dd/yyyy" orientation="auto" startDate="4/11/2015 3:30:40 PM" todayBtn="False" todayHighlight="True" data-val="true" id="Experience2" name="Experience2" placeholder="Select First Date" type="text" **data-val-daterangerequired="The Experience2 field is required."**> 
    <input class="form-control input-sm from_date" name="Experience2" placeholder="Select First Date" aria-invalid="false"> 
    <span class="input-group-addon">to</span> 
    <input class="form-control input-sm to_date" name="Experience2" placeholder="Select Secound Date" aria-invalid="false"> 
</div> 

回答

0

你可以用這個嘗試:

$("#id").datepicker({ 
    onClose: function() { 
    /* Validate a specific element: */ 
    $("form").validate().element("#birthdate"); 
    } 
});