ngx-mask icon indicating copy to clipboard operation
ngx-mask copied to clipboard

US ZipCode with optional +4

Open beaudetious opened this issue 5 years ago • 5 comments

I cannot get this to work for me at all: 00000-0?0?0?0?

My expectations: Input: 12345 Output: 12345

Input: 12345-6789 Output: 12345-6789

Anything else is invalid. Any suggestions?

beaudetious avatar Sep 04 '20 16:09 beaudetious

You can use multiple patterns, per https://github.com/JsDaddy/ngx-mask#dynamic-valid-mask :

<input mask="00000||00000-0000" />

rlmestre avatar Sep 16 '20 15:09 rlmestre

@rlmestre , Dynamic valid mask which version is available from? Because my project still uses Angular 8.

danilorb avatar Sep 22 '20 20:09 danilorb

@rlmestre , Dynamic valid mask which version is available from? Because my project still uses Angular 8.

You can use multiple patterns, per https://github.com/JsDaddy/ngx-mask#dynamic-valid-mask :

<input mask="00000||00000-0000" />

It does not work when loading a value like 88888-8888. The mask shows the value as 88888 when preloading.

divjyot3112 avatar Apr 15 '21 20:04 divjyot3112

Thank you. I'll give it a shot.

On Thu, Apr 15, 2021 at 4:50 PM Divjyot Singh Khanuja < @.***> wrote:

@rlmestre https://github.com/rlmestre , Dynamic valid mask which version is available from? Because my project still uses Angular 8.

You can use multiple patterns, per https://github.com/JsDaddy/ngx-mask#dynamic-valid-mask :

It does not work when loading a value like 88888-8888. The mask shows the value as 88888 when preloading.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JsDaddy/ngx-mask/issues/795#issuecomment-820721536, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7H7SJRYTNLLWNMSSSYGNLTI5GQDANCNFSM4QYZQERA .

beaudetious avatar Apr 15 '21 21:04 beaudetious

Thank you. I'll give it a shot. On Thu, Apr 15, 2021 at 4:50 PM Divjyot Singh Khanuja < @.***> wrote: @rlmestre https://github.com/rlmestre , Dynamic valid mask which version is available from? Because my project still uses Angular 8. You can use multiple patterns, per https://github.com/JsDaddy/ngx-mask#dynamic-valid-mask : It does not work when loading a value like 88888-8888. The mask shows the value as 88888 when preloading. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#795 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7H7SJRYTNLLWNMSSSYGNLTI5GQDANCNFSM4QYZQERA .

I just found the perfect solution to the problem: pattern='^[0-9]{5}(?:[0-9]{4})?$' mask="00000-0000" [validation]="false" [showMaskTyped]="true"

divjyot3112 avatar Apr 15 '21 21:04 divjyot3112

@beaudetious Thanks for your using Ngx-Mask. Please update to latest version. Dynamic mask work as expected.

andriikamaldinov1 avatar Jun 20 '23 08:06 andriikamaldinov1