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
4
votes
2 answers

Jquery inputmask casing uppercase/lowercase

Im using jquery inputmask How can I use below code to any input text with out a mask? any letter inputted will force to uppercase. Inputmask.extendAliases({ uppercase: { mask: '' // any letters definitions: { …
mrrsb
  • 663
  • 3
  • 13
  • 28
4
votes
2 answers

What is the proper way to import jquery.inputmask?

I'm having trouble importing jquery.inputmask with webpack and TypeScript. There is some discussion at Question: build this with webpack/es6 #1115 : Here's how i just set things up with jqlite Import in your app like so: import InputMask from…
user247702
  • 23,641
  • 15
  • 110
  • 157
4
votes
3 answers

Jquery input.mask with regex

I want to implement simple jquery mask pluging using jquery input.mask plugin, however, i cannot make it work with regex. What i want to achieve is: 99:59:59 Fiddle
agriboz
  • 4,724
  • 4
  • 35
  • 49
4
votes
3 answers

jQuery Input Masks for datetime input using American dates

I'm using Robin Herbot's excellent jQuery Input Masks plugin. [ https://github.com/RobinHerbots/jquery.inputmask ]. It's quite complete and seems to have everything I need, but I can't seem to figure one thing out. How do I create a mask like:…
pbarney
  • 2,529
  • 4
  • 35
  • 49
3
votes
0 answers

How to input less than 1$ using mouse in alias: "currency" with decimals , Inputmask

I`m using RobinHerbots input-mask: https://github.com/RobinHerbots/Inputmask You can refer to the currency demo according to this page: http://robinherbots.github.io/Inputmask/ and click the demo tab, then currency. Now to input less then $1 user…
3
votes
3 answers

jQuery Inputmask Plugin prevents form from submitting when a masked field has the "readonly" attribute

I am using this jQuery Plugin https://github.com/RobinHerbots/Inputmask to enable inputfield masking. In some forms I have to display readonly fields which also have a mask applied to them. This however prevents the form from being submitted via…
3
votes
0 answers

Inputmask oncomplete without JQuery

I set mask: and call inputmask for multiple elements: let els = document.querySelectorAll("input"); Inputmask().mask(els); How I can set oncomplete event after? I try like…
3
votes
1 answer

datetime format bug for jquery.inputmask 3.3.4?

when I upgrade my jquery.inputmask plugin from 3.3.1 to 3.3.4, I noticed that datetime format for mask is changed. // in version 3.3.1 $("#textbox").inputmask("y-m-d"); $("#textbox").inputmask("h:s"); // in version…
ineztia
  • 815
  • 1
  • 13
  • 29
3
votes
2 answers

Validate phone number with starting from certain number only in inputmask jquery

I am trying to validate phone number as following. After 61 it should be starting from 2 or 3 or 6 only. Examples are as follows. 61-245623463 : valid 61-345623456 : valid 61-445623423 : not valid 61-645623485 : valid My current code is as follows.…
Gayan Fernando
  • 581
  • 1
  • 7
  • 23
3
votes
1 answer

Angular2, inputmask ngModel binding

I have some problem with ng2 and inputmask. For example I have had this code component.html
3
votes
2 answers

Selenium SendKey conflict with jquery inputmask

I am using C# OpenQA.Selenium.Support.PageObjects and OpenQA.Selenium. In the page model, I tried to enter an email to the textbox which has an inputmask. [FindsBy(How = How.Id, Using = "Email")] private IWebElement _txtEmail; public string…
Blaise
  • 21,314
  • 28
  • 108
  • 169
3
votes
2 answers

jquery.inputmask - set value in "oncomplete" callback makes incorrect action

If in "oncomplete" callback make setVal action with other masked input, you can see incorrect reactions in Chrome and Safary, well work in FF oncomplete: function(e){ $('.i-input-2').val($(e.currentTarget).inputmask('unmaskedvalue')); } Demo:…
sglazkov
  • 1,046
  • 1
  • 10
  • 38
3
votes
1 answer

How to set up autoUnmask for jquery inputmask?

I have placed a currency input mask on the textbox. But when the form is submitted, the leading '$' sign and the separating commas need to be removed so that the value can be binded to as a decimal. Here is how I set the autoUnmask as described in…
Blaise
  • 21,314
  • 28
  • 108
  • 169
3
votes
2 answers

How to get unmask value in MVC controller

I am using jquery.inputmask.js in my project as $("#SSN").inputmask({ "mask": "999-99-9999", 'autoUnmask': true, onUnMask: function (value) { return value.replace('-', ''); } }); It…
user1882705
  • 1,081
  • 4
  • 15
  • 43
2
votes
1 answer

How to allow more than 3 periods with Jquery-Inputmask email extention alias

I have an issue at work none of us are seeming to find the answer to. We have a jquery input mask being applied with: $(".email-input").inputmask("email", {showMaskOnHover: false}); It works fine until we had a new user with an email that was…
1
2
3
12 13