Anooplal
Anooplal

Reputation: 1

How to avoid ngx bootstrap bsDatepicker default validations which shows "Invalid date" message in angular app

I want to avoid bsDatepicker default validations which shows "Invalid date" message in date picker input text box.I have my own validation for validating the date.I am using reactive angular form.I didn't find any sample for avoid bsDatepicker default validation.In all the example given in below link if we enter an invalid date like "sdad" immediately the default validation will trigger and shows the error message 'Invalid Date' in date picker input text box.How i can avoid that default validation. https://valor-software.com/ngx-bootstrap/#/datepicker

You can find the code sample for my scenario in below link. https://valor-software.com/ngx-bootstrap/#/datepicker#reactive-forms

Upvotes: 0

Views: 1698

Answers (1)

user2304483
user2304483

Reputation: 1644

Try this:

import {enGbLocale} from 'ngx-bootstrap/locale';
import {BsLocaleService, defineLocale, BsDatepickerConfig} from 'ngx-bootstrap';

In the constructor add the following:

constructor(                                            
      private localeService: BsLocaleService) {
`enGbLocale.invalidDate = ''`;
 defineLocale('custom locale', enGbLocale); 
 this.localeService.use('custom locale');
}

I hope it helps

Upvotes: 0

Related Questions