Questions tagged [jquery-inputmask]

jquery.inputmask is a jquery plugin which create an input mask. An inputmask helps the user with the input by ensuring a predefined format. This can be useful for dates, numerics, phone numbers, ...

jquery.inputmask

Copyright (c) 2010 - 2013 Robin Herbots Licensed under the MIT license (https://www.opensource.org/licenses/mit-license.php)

jquery.inputmask is a jquery plugin which create an input mask.

An inputmask helps the user with the input by ensuring a predefined format. This can be useful for dates, numerics, phone numbers, ...

Highlights:

  • easy to use
  • optional parts anywere in the mask
  • possibility to define aliases which hide complexity
  • date / datetime masks
  • numeric masks
  • lots of callbacks
  • non-greedy masks
  • many features can be enabled/disabled/configured by options
  • supports readonly/disabled/dir="rtl" attributes
  • support data-inputmask attribute
  • multi-mask support
  • regex-mask support

Usage:

Include the js-files which you can find in the dist-folder. You have the bundled file which contains the main plugin code and also all extensions. (date, numerics, other) or if you prefer to only include some parts, use the separate js-files in the dist/min folder.

The minimum to include is the jquery.inputmask.js

html

<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.inputmask.js" type="text/javascript"></script>

Define your masks:

javascript

$(document).ready(function(){
   $("#date").inputmask("d/m/y");  //direct mask
   $("#phone").inputmask("mask", {"mask": "(999) 999-9999"}); //specifying fn & options
   $("#tin").inputmask({"mask": "99-9999999"}); //specifying options only
});

or

html

<input data-inputmask="'alias': 'date'" />
<input data-inputmask="'mask': '9', 'repeat': 10, 'greedy' : false" />
<input data-inputmask="'mask': '99-9999999'" />

javascript

$(document).ready(function(){
    $(":input").inputmask();
});

Learn more:

190 questions
0
votes
2 answers

regex allows one character (it should not) why?

Hello I am trying to create a regex that recognizes money and numbers being inputted. I have to allow numbers because I am expecting non-formatted numbers to be inputted programmatically and then I will format them myself. For some reason my regex…
Jack Thor
  • 1,554
  • 4
  • 24
  • 53
0
votes
1 answer

jQuery inputmask makes CKEditor adapter to stop working

I have the following form: Publish Start - 2x inputs, one for time, one for date; Publish End - 2x inputs, one for time, one for date; Post Content - 1x textarea. The inputs for date/time use jQuery InputMask and textarea use CKEditor (with jQuery…
RaphaelDDL
  • 4,452
  • 2
  • 32
  • 56
-1
votes
2 answers

How to mask a decimal input using Jquery?

I have previously used Telerik's RadNumericTextBox for giving input of decimals like below:
Setu Kumar Basak
  • 11,460
  • 9
  • 53
  • 85
-1
votes
3 answers

Regular expression for decimals from 1 to 9 , or 10 without floating

I have an html field that need to restrict the user input to either type number from 1 to 9 with a precision of two numbers, or just the number 10, so that the number 10 could not have a precision. for exp : 5.50 ,7 , 6.45 , 10 // tolerated…
krachleur
  • 356
  • 3
  • 14
-1
votes
1 answer

Convert short year format to full - jquery input mask

I have Jquery input mask date that has format mm/dd/yyyy. When I type 17 for a year I want to convert it to 2017 and that works good but I have the issue when I type 21 it converts to 201 not 2021. You can here see…
Edin Puzic
  • 998
  • 2
  • 19
  • 39
-1
votes
1 answer

Regex with inputmask for commas

$("#xyz").inputmask('Regex', {regex: "^[0-9]{1,8}(\\.\\d{1,2})?$"}); Above expression allows me to enter 8 digits and 2 decimals but it doesn't automatically handle commas. Can any one help me with commas.
Nain
  • 97
  • 3
  • 11
-1
votes
1 answer

Turn Regular Expression into Javascript input mask

Ultimately I want a mask that only allows an integer to be entered, or if a decimal/period is entered: allow 0 - 2 digits after the decimal point. Valid Input 1 1. 1.1 1.11 111111111 111111111. 111111111.1 111111111.11 Invalid…
Neil
  • 4,578
  • 14
  • 70
  • 155
-2
votes
1 answer

How to unmask on submit RobinHerbots / Inputmask

I use this plugin and want to unmask input on submit.
zzk
  • 19
  • 5
-2
votes
1 answer

How to specify a jquery inputmask that is either a number or a fixed string?

The goal is for the user to input a 9 digit number or a string with the value "YOUR NAME". Something like: I know that doesn't work, but I've tried a lot of different…
Todd Hoff
  • 712
  • 5
  • 12
-3
votes
1 answer

Mask input formate for decimal 3 digits

I stuck with input mask format for decimal 3 digits. For example, if user input 1 then it should be automatically formatted to 0.001 if user input 11 then it should be 0.011 means input digit start from right to left but I need to maintain 3 digits…
1 2 3
12
13