Jquery Input Mask - keep the placeholder permanently

Hi all,

Im using https://igorescobar.github.io/jQuery-Mask-Plugin .

How can I keep the placeholder all the time? At the moment it disappears when you start typing. I need it to be there even after they’ve completed filling it in.

The reason why I need this is because I need to the user to inut exactly what is there. For example:
The value the user enter must be 00.0, or 000.0. (Its got to be 1 decimal place, but they can enter up to 3 numbers before the decimal).

At the moment when I type 88 it shows as 8.8, and 987 shows as 98.7.

My code:
$(‘#my_field’).mask(‘000.0’, {placeholder: “__.”, reverse: true});

So having the placeholder there permanently shows them that they need to enter it accurately. Or is there a better way to achieve this?

If you don’t want it to disappear, put it in the label, not the placeholder.

Yes, but I think it looks nicer having within the input itself.
I thought this would be relatively simple thing to achieve, but maybe not(?)

You can do something like this if you want text in the input to start with.

Nor sure how it would tie into your existing system of course.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.