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
15
votes
8 answers

How to remove underline from jQuery input mask plugin textboxes

I want to remove underline from masked input implemented using jQuery inputmask plugin- http://github.com/RobinHerbots/jquery.inputmask
nickalchemist
  • 2,211
  • 6
  • 31
  • 58
13
votes
2 answers

How connect jquery.inputmask using requirejs

How correctly connect https://github.com/RobinHerbots/jquery.inputmask using requirejs? Method on official site documentation not correct. I try make it like this require-config.js paths: { ... inputmask:…
sglazkov
  • 1,046
  • 1
  • 10
  • 38
11
votes
3 answers

2 decimal places inputmask

I'm using RobinHerbots inputmask , How can I make 2 decimal places like 22.30 or 2.15? like 'currency' set up on the inputmask but without commas (auto generated base on values length) and currency sign. Below is my snippet of what I've tried but…
Juliver Galleto
  • 8,831
  • 27
  • 86
  • 164
8
votes
2 answers

JQuery input mask for 12 hour time format

I am using the jquery inputMask library(https://github.com/RobinHerbots/jquery.inputmask). But feel free to let me know if there is a better inputMask library. But I need inputMask, not a time picker. The scenario is to have inputMask on the time…
Lance Shi
  • 1,127
  • 3
  • 13
  • 28
8
votes
4 answers

Range 0-100 using jQuery inputmask plugin

How can I create mask for range from 0 to 100? $(document).ready(function() { $("#masked").inputmask(???); });
NieAR
  • 1,385
  • 6
  • 20
  • 31
8
votes
3 answers

How to make jquery.inputmask work with input type=number?

I have the code working fine using this plugin as long as the input type=text, but I would like to use type=number so the proper keyboard is shown on mobile devices. Is there a way to do this, hopefully with some setting I have missed in the…
Nathaniel
  • 113
  • 1
  • 1
  • 6
7
votes
1 answer

jQuery inputmask no limit on number of characters

I'm using the jQuery inputmask plugin for masking a text field (https://github.com/RobinHerbots/Inputmask). I can't figure out the syntax for masking an unlimited number of alphanumeric characters. This seems like it should be simple I just can't…
wzsmith1
  • 73
  • 1
  • 5
7
votes
2 answers

Change the currency symbol or remove it in the inputmask currency

I'm using Robin Herbot's inputmask jquery plugin and I want to change the default currency symbol (by default, its a dollar currency symbol) to a PESO currency symbol or remove the currency symbol. Below is what I've tried, yes the symbol changes…
Juliver Galleto
  • 8,831
  • 27
  • 86
  • 164
6
votes
3 answers

jQuery input mask for phone number

I want a user's input to autofill the punctuation of a phone number in order to look like this (xxx) xxx-xxxx. This is my HTML code:
6
votes
3 answers

Jquery.inputmask not working

Trying to use Robin Herbots Inputmask module, and can't get it working. Looking at all the other similar posts, a common problem to make sure the docment.ready function has a call to inputmask(), but this looks good to me. Scripts
ImTalkingCode
  • 353
  • 1
  • 3
  • 14
6
votes
1 answer

Should email validation requires the domain part contains a dot?

I noticed that the built-in browser validation for requires a format of xxx@xxx. Only the @ character is required. There is no need to a dot, like email@stackoverflow.com. It is the same with the popular jQuery.inputmask, the…
Blaise
  • 21,314
  • 28
  • 108
  • 169
5
votes
1 answer

InputMask with Autocomplete

I want to make input for dateTime with mask and with autocomplete. I've created small demo where the problem exists. Looks like autocomplete thinks mask is a text... only if I finish input I can see some value from autocomplete (if it exists in…
demo
  • 6,038
  • 19
  • 75
  • 149
5
votes
3 answers

inputmask must allow unlimited digits

So below is my snippet, currently inputmask allow only this format "_." (e.g 5.55). Is there a way I could extend the format like I want this format "._____________.." (e.g 55.555555555555555555555... where after 55. the rest of the input digits…
Juliver Galleto
  • 8,831
  • 27
  • 86
  • 164
4
votes
1 answer

How to use Select2 with Inputmask

I am trying to create a Select2 box with InputMask to insert IP addresses and add them as tags. If I use any of the libraries on its own, it works like a charm but both together results in strange behavior. When I type in numbers, the mask is not…
Ti-m
  • 71
  • 11
4
votes
1 answer

Regex for feet and inches - with decimals and fractions

I'm creating an input mask used to for the length of items. This input will convert to a "proper" format on blur but it should accept numbers, decimals, spaces, single quotes, double quotes and / for fractions (no letters). I've got an okay start,…
triplethreat77
  • 1,276
  • 8
  • 34
  • 69
1
2 3
12 13