Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date input as a text type
Message
General information
Forum:
Javascript
Category:
Other
Miscellaneous
Thread ID:
01605625
Message ID:
01605841
Views:
29
We have rather complicated directive so using Date or DateTime type will not really work. I am sold on custom validator as Viv shown.

>I would stick with Date or DateTime HTML5 fields and conditionally load the right one as that would be a lot easier to let Angular do it's standard validations on the date types.
>
>Otherwise you have to create a custom validator that checks the date.
>
>+++ Rick ---
>
>>Hi everybody,
>>
>>We have a nice complex directive with the following template:
>>
>>
>><div class="input-group">
>>    <input type="text" autocomplete="off" id="{{name}}" name="{{name}}" class="form-control" placeholder="{{placeholder}}" />
>>    <span class="input-group-addon datepickerbutton">
>>        <!--datepickerbutton:jquery datetimepicker plugin requires this class-->
>>        <i class="icon-calendar"></i>
>>    </span>
>>    <span class="input-group-addon datetimepicker-input-addon-button" ng-if="showBod" ng-click='setBod()'><i class="icon-sun"></i></span>
>>    <span class="input-group-addon datetimepicker-input-addon-button" ng-if="showEod" ng-click='setEod()'><i class="icon-moon"></i></span>
>>    <span class="input-group-addon datetimepicker-input-addon-button" ng-if="showNow" ng-click='setNow()'>Now</span>
>></div>
>><div class="field-validation-error">
>>    <span ng-show="!validStartDateRange()">Start date must begin before end date.</span>
>>    <span ng-show="!validEndDateRange()">End date must begin after start date.</span>
>>    <span ng-show="!validRequired()">Date is required.</span>
>>    <span ng-show="!validFutureDate()">Date must be in the future.</span>
>>    <span ng-show="!validPastDate()">Date must be in the past.</span>
>></div>
>>
>>
>>The problem is that I can type any garbage text in the date field. The date is not saved in this case, but I'd rather have it automatic validation for valid date format. I know there is HTML 5 date type, but it doesn't work in our situation as this directive should work for both date and datetime and also it has its own date picker which is called from an extra button.
>>
>>So, do you know what can be done to make sure the input is correct date?
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform