RobinHerbots / Inputmask

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

Question Not Bug #2776

Closed cengizilhan closed 3 months ago

cengizilhan commented 4 months ago

Hi all,

Im using like that. I wanna try native html validator. But if i write: "53_-____" minlenth is 9 but there is too much char return from the .value property. so its not works. Is there anyway for work it ?

<input minlength="9" pattern=".{9,}" title="Cannot be empty" required type="tel" class="form-control" id="Phone" name="Phone" data-inputmask="'mask': '999-9999999' " />

I guess only way is only number with regex. no mask ?

Techn1c4l commented 4 months ago

You have the default placeholder set to underscore character which fills the string so it satisfies the minlength requirement. To disable this, set the placeholder option to an empty string '' like this: <input minlength="9" pattern=".{9,}" title="Cannot be empty" required type="tel" class="form-control" id="Phone" name="Phone" data-inputmask="'mask': '999-9999999', 'placeholder': ''" /> Remember than the native HTML validation will just set Element.validity.valid to either true or false which is not so useful.

cengizilhan commented 4 months ago

thank you! its works