user3900456
user3900456

Reputation: 2003

Add text literal to jquery input mask

I'm using jQuery Input Mask and I'm setting a mask using data-inputmask="'alias': 'integer', 'radixPoint': ',', 'rightAlign': false, 'allowMinus': false, 'allowPlus': false, 'autoGroup': true, 'groupSeparator': '.', 'autoUnmask': true"

I want to add the text literal "km" after the value so the mask will be something like 15.000 km

How can I do that? Is it possible to do it using just the data-inputmask attribute?

Upvotes: 2

Views: 5619

Answers (1)

Prabhakar Kasi
Prabhakar Kasi

Reputation: 529

You should make use of the property

'suffix': ' km'

Simple settings

<input style="text-align: right;" data-inputmask="'alias': 'numeric', 'groupSeparator': ',', 'autoGroup': true, 'digits': 2, 'digitsOptional': false, 'suffix': ' km', 'placeholder': '0'">

From your settings

<input style="text-align: right;" data-inputmask="'alias': 'numeric', 'rightAlign': false, 'allowMinus': false, 'allowPlus': false, 'autoGroup': true, 'groupSeparator': ',', 'autoUnmask': true, 'digits': 2, 'suffix': ' km', 'placeholder': '0', 'digitsOptional': false">

Upvotes: 2

Related Questions