清除最大日期时的无效日期错误

时间:2019-05-03 05:41:16

标签: javascript c# html5

我有两个输入字段,分别是日期选择器“ startDate”和“ endDate”。对于startDate,最大日期应为endDate。对于endDate,最小日期应为startDate。当我清除startDate并尝试为endDate设置新日期时,它会显示“无效日期错误”,因为min-Date(StartDate)值已清除。请帮助我

<div class="col l2 m4 s12 input-field">
    <input id="startDate" type="text" ng-model="startDate" date-picker="date" format="D/M/YYYY" max-date="endDate" />
    <label material-active="startDate" for="startDate">Min. Created Date</label>
    <a class="clear-button" href="#" ng-click="clearDate($event, 'startDate')" ng-show="startDate">X</a>
</div>
<div class="col l2 m4 s12 input-field">
    <input id="endDate" type="text" ng-model="endDate" date-picker="date" format="D/M/YYYY" min-date="startDate" />
    <label material-active="endDate" for="endDate">Max. Created Date</label>
    <a class="clear-button" href="#" ng-click="clearDate($event, 'endDate')" ng-show="endDate">X</a>
</div>


scope.clearDate = function (e, prop) {
                            e.preventDefault();
                            scope[prop] = '';
                        }

1 个答案:

答案 0 :(得分:0)

请检查您的日期格式值format="D/M/YYYY" 尝试使用format="dd/MM/yyyy"