RobinHerbots / Inputmask

Input Mask plugin
https://robinherbots.github.io/Inputmask/
MIT License
6.37k stars 2.17k forks source link

[Question] How to custom placeholder in "ip" alias? #2749

Closed KiddoV closed 9 months ago

KiddoV commented 9 months ago

I am trying to make the place holder look like this "___.___.___.___", but no matter what I do, it's still showing "_._._._". Is anyone know how to fix that?

import Inputmask from 'inputmask';

const ipv4Inputs = document.querySelectorAll("input[type='ipv4']");
ipv4Inputs.forEach((input: HTMLInputElement) => {
    Inputmask({alias: "ip", greedy: false, placeholder: "___.___.___.___", clearIncomplete: true}).mask(input);
});

I have tried placeholder: "___.___.___.___", but it doesn't work.

Thanks,

RobinHerbots commented 9 months ago

Have you tried with greedy: true?

KiddoV commented 9 months ago

Thanks, it works, but the behavior is not what I expected. When you type a 2 digit number like "99", it doesn't automatically jump to the next IP section anymore:

99_.___.___.___

You have to type 99 then space. Without greedy, it would automatically jump to the next section if you type a number that bigger than 255, so when I type 99999999 without space it would mask 99.99.99.99. Now, it just stop when I keep type 9.

RobinHerbots commented 9 months ago

@KiddoV ,

Hmm yes, that would be a good enhancement. 999 is an impossible value so it should jump to the next section.

KiddoV commented 9 months ago

In the meantime, is there any work around for this you can suggest?

RobinHerbots commented 9 months ago

It is fixed in version 5.0.9-beta.35

RobinHerbots commented 9 months ago

Correction, almost fixed, .... I just discovered an issue. Anyway you can already have look on the demo page.

KiddoV commented 9 months ago

Thanks for the update!

RobinHerbots commented 9 months ago

It is fixed in version 5.0.9-beta.36