Closed biaolu504 closed 3 years ago
The range validation is working as expected. The max
prop of the picker is set to 01/01/2100
by default, so any date after it will produce a max
validation form error. You can explicitly set the max
prop to whatever value you like though.
For the incomplete date, you can add a required
validator, which will notify the end user that 02/26/year
actually holds no value (as it's an invalid date).
There is no solution out-of-the-box for the scenario where the date is not required, but you do want to notify the end user that he's typed an incomplete date. We will consider implementing such a form validator (guarding only against incomplete values).
@biaolu504, thanks for pointing this out. I've changed the name of the thread to better reflect the missing validator issue.
Feature available in latest dev version.
Feature available in 4.4.0 https://www.telerik.com/kendo-angular-ui/components/dateinputs/dateinput/incomplete-dates/
but still this is not firing as expected. it fires only when you enter the invalid date(like 2/2/2) and then to 2/2/year it fires. If you try enter for 2/2/year then its not firing the validation.
Kindly reopen and fix the issue.
Hi @saravanakumarrc, Thank you for your feedback.
Are you referring to the fact that the control does not show the "invalid" styles (orange border) until some segment of the value is cleared like in the video below?
If that is your concern, I would like to say that this is the expected behavior.
The control only shows its "invalid" styles (orange border) when it is both invalid and (the control is touched || dirty). In the video example, we have a state change from null
to a valid date (2/2/2), and then back to null
, which makes the component's state dirty
, which, in turn, reveals the validation to the end user by displaying the invalid styles.
As you can see from the recording above, the { "incompleteDate": true }
error is still there, albeit not visible to the end user.
Please do let us know if I am missing something. Regards, Georgi
@gkarapeev I need the behaviour as mentioned in the video. but its not working for reactive forms. Please verify https://stackblitz.com/edit/angular-skj5fz?file=app/app.component.ts
@gkarapeev and you will see same working when enter full date fields and remove just a year.
@saravanakumarrc it seems like this is exactly the intended behavior. The reason why the validation lights up in your example is that you also have a min
date, which is later than the selected value, and the control is dirty as soon as we enter a value.
Here are some useful links on the topic:
To prevent the validator from displaying errors before the user has a chance to edit the form, you should check for either the dirty or touched states in a control. When the user changes the value in the watched field, the control is marked as "dirty". When the user blurs the form control element, the control is marked as "touched".
Finally, if you use the FormField component, you can customize when the validation styles are applying via the ShowErrors input. The default option is initial
:
(Default) initial—Allows displaying errors when the form-bound component state is invalid and touched or dirty.
A simpler workaround would be to just override the CSS of your kendo-theme so that it does not show validation for controls with the class ng-dirty
.
@gkarapeev I am saying the incomplete date validation is not firing up. getting min/max error is not problem. I have updated the same without min/max. but still you can see the incomplete date error is not occurring in the reactive forms. https://stackblitz.com/edit/angular-skj5fz?file=app/app.component.ts
Note: if the field is required it will occur.
I have found the issue, the formcontrol's default value was '' empty string. it should be null. it works if its null.
Thank you, @saravanakumarrc, you are right, I see it now. Will look further into it.
I'm submitting a...
Current behavior
You can leave the date entry as '02/26/year' and submit it. The value would be Null, and there is no validation to catch it.
Expected behavior
should have a validation error of 'Invalid date'
Minimal reproduction of the problem with instructions
Select a date from datepicker, i.e. 02/26/2020. The textbox will be populated with "02/26/2020", highlight the year part ("2020"), press delete. Text become "02/26/year". There is no validation on this, no error. You can submit it in a form, the value is Null.
Go to "Date Ranges" of Datepicker documentation. Click on "OPEN IN STACKBLITZ'. Change the date from '3/10/2001' to '3/10/2100'. Validation will report error: Errors: { "maxError": { "maxValue": "2002-03-10T05:00:00.000Z", "value": "2100-03-10T05:00:00.000Z" } }. Datepicker is highlighted with a red border.
Highlight the year part and press 'delete', date become '3/10/year', no error is reported. When submit, Datepicker has Null value
Environment
Package versions: [feature/8162 ≡ +2 ~7 -0 !]> npm ls --depth 0 front-end@0.0.0 C:\DevRepos\ASPEN\Web\V11.0\src\Asi.Common.WebApp\FrontEnd +-- @angular-devkit/build-angular@0.803.22 +-- @angular/animations@8.2.14 +-- @angular/cdk@8.2.3 +-- @angular/cli@8.3.22 +-- @angular/common@8.2.14 +-- @angular/compiler@8.2.14 +-- @angular/compiler-cli@8.2.14 +-- UNMET PEER DEPENDENCY @angular/core@8.2.14 +-- @angular/flex-layout@8.0.0-beta.27 +-- UNMET PEER DEPENDENCY @angular/forms@8.2.14 +-- @angular/language-service@8.2.14 +-- @angular/material@8.2.3 +-- @angular/platform-browser@8.2.14 +-- @angular/platform-browser-dynamic@8.2.14 +-- @angular/router@8.2.14 +-- @aspen/scss@1.0.0 -> C:\DevRepos\ASPEN\Web\V11.0\src\Asi.Common.WebApp\FrontEnd\libs\shared\theme\scss +-- @compodoc/compodoc@1.1.11 +-- @microsoft/office-js@1.1.36 +-- @microsoft/office-js-helpers@1.0.2 +-- @ngrx/effects@8.6.0 +-- @ngrx/entity@8.6.0 +-- @ngrx/router-store@8.6.0 +-- @ngrx/store@8.6.0 +-- @ngrx/store-devtools@8.6.0 +-- @ngx-progressbar/core@5.3.2 +-- @ngx-translate/core@11.0.1 +-- @ngx-translate/http-loader@4.0.0 +-- @nrwl/angular@8.11.0 +-- @nrwl/cypress@8.11.2 +-- @nrwl/jest@8.11.2 +-- UNMET PEER DEPENDENCY @nrwl/workspace@8.11.2 +-- @progress/kendo-angular-buttons@5.2.0 +-- @progress/kendo-angular-common@1.2.1 +-- @progress/kendo-angular-dateinputs@4.2.0 +-- @progress/kendo-angular-dropdowns@4.2.4 +-- @progress/kendo-angular-excel-export@3.1.0 +-- @progress/kendo-angular-grid@4.6.2 +-- @progress/kendo-angular-inputs@6.4.0 +-- @progress/kendo-angular-intl@2.0.1 +-- @progress/kendo-angular-l10n@2.0.1 +-- @progress/kendo-angular-layout@4.2.0 +-- @progress/kendo-angular-menu@2.0.2 +-- @progress/kendo-angular-pdf-export@2.0.1 +-- @progress/kendo-angular-popup@3.0.4 +-- @progress/kendo-angular-treeview@4.0.1 +-- @progress/kendo-angular-upload@5.1.0 +-- @progress/kendo-data-query@1.5.2 +-- @progress/kendo-drawing@1.6.0 +-- @progress/kendo-theme-default@4.11.1 +-- @progress/kendo-ui@2019.3.1114 +-- @types/jasmine@3.5.0 +-- @types/jasminewd2@2.0.8 +-- @types/jest@24.0.25 +-- @types/jquery@3.3.31 +-- @types/node@13.1.6 +-- @types/office-js@1.0.60 +-- @types/office-runtime@1.0.10 +-- angular2-multiselect-dropdown@4.6.3 +-- babel-polyfill@6.26.0 +-- bootstrap@4.4.1 +-- codelyzer@5.2.1 +-- core-js@3.6.4 +-- cypress@3.8.2 +-- hammerjs@2.0.8 +-- html2canvas@1.0.0-rc.5 +-- increase-memory-limit@1.0.7 +-- jasmine-core@3.5.0 +-- jasmine-marbles@0.6.0 +-- jasmine-spec-reporter@4.2.1 +-- jest@24.9.0 +-- jest-preset-angular@8.0.0 +-- jquery@3.4.1 +-- jquery-ui@1.12.1 +-- jquery-ui-dist@1.12.1 +-- lodash.clonedeep@4.5.0 +-- moment@2.24.0 +-- ng2-dnd@5.0.2 +-- ng5-slider@1.2.4 +-- ngrx-store-freeze@0.2.4 +-- ngrx-store-logger@0.2.4 +-- ngx-bootstrap@5.3.2 +-- ngx-color-picker@8.2.0 +-- ngx-spinner@8.1.0 +-- ngx-toastr@11.3.0 +-- office-ui-fabric-js@1.5.0 +-- UNMET PEER DEPENDENCY popper.js@^1.16.0 +-- precise-commits@1.0.2 +-- prettier@1.19.1 +-- protractor@5.4.2 +-- quill@1.3.7 +-- rxjs@6.5.4 +-- rxjs-compat@6.5.4 +-- rxjs-tslint@0.1.7 +-- ts-jest@24.0.0 +-- ts-node@8.6.2 +-- tslib@1.10.0 +-- tslint@5.20.1 +-- typescript@3.4.5 `-- UNMET PEER DEPENDENCY zone.js@0.10.2
Browser:
System: