Jquery.inputmask 不工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28510610/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jquery.inputmask not working
提问by ImTalkingCode
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.
尝试使用 Robin Herbots Inputmask 模块,但无法正常工作。查看所有其他类似的帖子,这是确保 docment.ready 函数调用 inputmask() 的常见问题,但这对我来说看起来不错。
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
mainReady-client.js
$(document).ready(function() {
$(":input").inputmask();
});
HTML
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.
看似简单,却什么也没有发生。这必须是我加载东西的顺序,但一切看起来都不错。谢谢你的帮助。干杯。
回答by Lumi Lu
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>
<!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>
回答by Abrar Jahin
You can use this CDN-
您可以使用此 CDN-
https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/3.1.60/inputmask/jquery.inputmask.js
A working demo is given here for you-
这里为您提供了一个工作演示-
$("#piash").inputmask("A-999");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/3.1.60/inputmask/jquery.inputmask.js"></script>
<td>
<input value="A-45" id="piash">
</td>
回答by BAGman
While this question is old I believe I have found a solution for those with a similar problem. The noConflict() function fixed it.
虽然这个问题很老,但我相信我已经为那些有类似问题的人找到了解决方案。noConflict() 函数修复了它。
<script type='text/javascript'>
$j=jQuery.noConflict();
$j(document).ready(function () {
$j("#currIN").inputmask("9999");
});
</script>