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

jQuery inputmask keeping placeholder text

I'm using jquery.inputmask (https://github.com/RobinHerbots/jquery.inputmask) and I want to do something like this: Have the initial input for an element be: "Hello my name is_" and then the cursor would start at the end and you could type in your…
stytown
  • 1,642
  • 2
  • 16
  • 22
0
votes
1 answer

match datetime pattern with spring DatetimeFormat annotation

I'm trying to use this jquery input mask plugin to submit a date time field. The input is being submitted as: 081220151530 - which is 3:30pm 08/12/2015 or in am/pm it's submitting 081220150330p I'm trying to bind that value to a Joda DateTime field…
Richard G
  • 5,243
  • 11
  • 53
  • 95
0
votes
1 answer

How to maintain the jquery inputmask when the DOM is updated?

Hard to describe. Here is a snippet. (function() { var PhoneNumber = function() { this.name = ko.observable(); this.phone = ko.observable(); }; $('[data-mask="phone"]').inputmask({ mask: '(999)999-9999' }); …
Blaise
  • 21,314
  • 28
  • 108
  • 169
0
votes
1 answer

Converting jQuery plugin to AngularJS Directive

I'm trying to use Input Mask jQuery plugin as a directive but getting the following error in Chrome's console errors. TypeError: Cannot read property 'length' of undefined My code JS var app = angular.module('app',…
Body
  • 3,608
  • 8
  • 42
  • 50
0
votes
1 answer

Mask does not work correct way at RobinHerbots inputmask plugin

I have this input mask FIDDLE: but I do not want thousand separator (dot) to be visible until user types in 4th digit. So, currently the input is: 1,--€ …
skobaljic
  • 9,379
  • 1
  • 25
  • 51
0
votes
1 answer

jQuery input mask with two different user inputs

I'm trying to create an input mask, which collects two different values from the user. In the end the input mask should look like this: [X.XXX$ for X years] Where the X is an input by the user. Ist that possible? I've tried by using the jQuery…
herby86
  • 1
  • 2
0
votes
1 answer

Can't able to make jquery input mask work

I couldn't for some reason get the jquery input mask plugin to work. I didn't know jquery so any person whom had worked in jquery please reply. here is my testPage.php code