kalai vani
kalai vani

Reputation: 289

Angular js md-datepicker allows to enter characters

I am using md-date-picker in angular js.It allows typing characters and numbers.How to avoid entering numbers or texts in date-picker without disabling the date-picker.Please help me regarding this.

<md-input-container  flex>
    <md-datepicker md-open-on-focus ng-model="field.start_date" readonly="readonly" 
                   md-min-date="vm.minDate" ng-change=" vm.getdata(field.start_date)"
                   md-placeholder="Date From">
    </md-datepicker>
</md-input-container>

Upvotes: 2

Views: 1817

Answers (1)

the_mishra
the_mishra

Reputation: 833

There is a work around for this issue, until angular-material updates this. You could use onkeydown="return false". It works pretty well.

<md-input-container  flex>
<md-datepicker md-open-on-focus ng-model="field.start_date" readonly="readonly" onkeydown="return false" 
               md-min-date="vm.minDate" ng-change=" vm.getdata(field.start_date)"
               md-placeholder="Date From">
</md-datepicker>

Hope it will help!!

Upvotes: 4

Related Questions