#Date is accepting 3 digit year

11 messages · Page 1 of 1 (latest)

gritty vine
#

I donot want my date field to accept year below 4 digit. How can I achieve this?

#

<date-input [form]="form" control="dateOfLoss" minlength="10" label="Date Of Loss" col=6 ></date-input>

#
// your code here
selector: 'date-input',
    template: `
    <div [formGroup]="form" [ngClass]="{ 'form-group-inline' : _inline , 'ax-form-group' : true }">
        <div class="label-line" [ngClass]="labelClass"  *ngIf='label !== undefined'>{{label}}<span *ngIf="!!_required" class="required-text">*</span><span class="text-muted" *ngIf="help != null">{{help}}</span></div>
        <div>
        <ejs-datepicker 
            formControlName="{{control}}" 
            [min]='min' 
            [max]='max' 
            [enableMask]='true' 
            [maskPlaceholder]="{month: 'mm', day: 'dd', year: 'yyyy'}" 
            [placeholder]="placeholder ?? ('Enter ' + (label ?? 'date'))"
            > </ejs-datepicker>
        <print-error [control]="this.form.controls[control]"></print-error>
        </div>
    </div> 
gritty vine
#

please help

ripe wadi
#

Your date picker apparently has a min input. Presumably, it's the minimum data that can be entered into the date picker. So pass it the minimum date you want to accept: (i.e. the first of January of year 1000)?

gritty vine
#

Actually the min is already defined as

#

min: any = new Date(1910,1,1)

#

when I open the datepicker it is blocking the dates before the min and after the max to select

#

but I can still type the improper date as 11/11/111 in the date field

ripe wadi
gritty vine
#

got it