DatePicker Mask Issue

Dear Team,

I have some requirement that is below.

1 User should input day, month and year from left to right.

2 If user type 1 in the day or month then 0 automatically add before 1 like 01,02,03 etc. I want user type both 01,02,05 ,10,15 instead of automatically add 0.


5 Replies

SP Sureshkumar P Syncfusion Team October 14, 2022 09:33 AM UTC

Hi Nagendra,

we suggest you use the format property when you need to change the entered value to single or two-digit values. 

find the code example here:

[component.html]

<p>Format: M/d/yyyy for single digit values</p>

    <ejs-datepicker

      [format]="format1"

      [enableMask]="enableMaskSupport"

    ></ejs-datepicker>

    <p>Format: MM/dd/yyyy for double digit values</p>

    <ejs-datepicker

      [format]="format"

      [enableMask]="enableMaskSupport"

    ></ejs-datepicker>

  </div>


[component.ts]

public format1string = 'M/d/yyyy';

  public formatstring = 'MM/dd/yyyy';


find the sample here: https://stackblitz.com/edit/angular-vqucjy?file=app.component.ts,app.component.html 

Note: If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.

Regards,

Sureshkumar P



NG Nagendra Gupta replied to Sureshkumar P October 14, 2022 02:29 PM UTC

Dear Sureshkumar P ,

In your previous example my requirement is not full fulling. When I am typing 1 in [dd] 0 is adding before it.  Typing of day, month and year from left to right instead of right to left.

Actually I want typing manually not automatic. In your Datepicker Mask Control 0 is adding before any typing. Again I am repeating typing should be start left to right.

Please give me appropriate solution for it.


Regards

Nagendra Gupta



NG Nagendra Gupta October 15, 2022 05:31 AM UTC

Dear Sureshkumar P ,

I have attached file which I actually want? Please find the attach file.


Regards

Nagendra Gupta


Attachment: demo_80a411ce.zip


SP Sureshkumar P Syncfusion Team October 17, 2022 12:40 PM UTC

Hi Nagendra,


We will validate the requirement in our component. We update you in two business days (October 19th, 2022).


Regards,


Sureshkumar P



SP Sureshkumar P Syncfusion Team October 19, 2022 09:58 AM UTC

Hi Nagendra,

This is the default behavior of our component. When you use the format as [dd] then our component inserted 0 before the single digit value like 01. If you don’t want to allow the 0 before the single digit number, then we suggest you use the format as [d] instead of [dd].

Regards,

Sureshkumar P


Loader.
Up arrow icon