jquery - Keeping Kendo Datepicker in min/max range -
when user types type in date outside of range, we're trying ensure date gets changed closest min/max. text displayed in date picker not change though thought script changing value()
@(html.kendo() .datepickerfor(x => x.dob) .max(new datetime(datetime.now.addyears(-18).year, datetime.now.addyears(-18).month, datetime.now.addyears(-18).day)) .min(new datetime(datetime.now.addyears(-70).year, datetime.now.addyears(-70).month, datetime.now.addyears(-70).day)) .events(e=>e.change("ondobchange")) .htmlattributes(new { required = "required", ng_model = "model.dob" })) <p ng-show="validatestate.submitted && frmmain.dob.$invalid" class="help-block">please select</p> <script> function ondobchange(e) { var dt = $("#dob").data("kendodatepicker"); if (dt.value() < dt.min()) { dt.value(dt.min()); }else if (dt.value() > dt.max()) { dt.value(dt.max()); } } </script>
i have solution, check null in val() , go element out:
Comments
Post a Comment