Jquery.inputmask not working

ImTalkingCode picture ImTalkingCode · Feb 14, 2015 · Viewed 42.2k times · Source

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

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
<script src="/js/jquery.inputmask.js">
<script src="/js/mainReady-client.js">
<script src="/js/bootstrap.min.js">

mainReady-client.js

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

HTML

<td>
  <input value="10" data-inputmask="'mask': '999'">
</td>

I've tried:

$(document).ready(function() {
  $("#currIN").inputmask("9999");
});

or (the real one I want - currency)...

$(document).ready(function() {
  $("#currIN").inputmask("'alias': 'numeric', 'groupSeparator': ',', 'autoGroup': true, 'digits': 2, 'digitsOptional': false, 'prefix': '$ ', 'placeholder': '0'");
});

and then:

<td>
  <input value="10" id="currIN">
</td>

It seems so simple yet nothing happens. It has to be the order that I load things, but it all looks good. Thanks for any help. Cheers.

Answer

Lumi Lu picture Lumi Lu · Feb 14, 2015

Try to use this inputmask script,

<script type='text/javascript' src="https://rawgit.com/RobinHerbots/jquery.inputmask/3.x/dist/jquery.inputmask.bundle.js"></script>

Working example JSFIDDLE

<!DOCTYPE html>
<html>
<head>
  <script type='text/javascript' src='http://code.jquery.com/jquery-1.11.0.js'></script>
  <script type='text/javascript' src="https://rawgit.com/RobinHerbots/jquery.inputmask/3.x/dist/jquery.inputmask.bundle.js"></script>

<script type='text/javascript'>
//<![CDATA[ 
  $(window).load(function(){
    $("#currIN").inputmask("9999");
  });
//]]> 
</script>
</head>
<body>
  <td>
  <input value="10" id="currIN">
</td>
</body>
</html>