admin管理员组文章数量:1344313
I'm using RobinHerbots jquery input mask.
How to redefine the "9", so the mask will show XXXX91 instead of XXXXX1?
EDIT: if possible I would like to make last two digits uneditable
var autoPopulateNo = 91 //how to show the mask like this XXXX91
$("#number").inputmask({
"mask": "9999" + autoPopulateNo,
clearMaskOnLostFocus: false,
placeholder:"X",
});
<script src=".1.1/jquery.min.js"></script>
<script src=".1.1/jquery.min.js"></script>
<script src=".cdpn.io/3/jquery.inputmask.bundle.js"></script>
<form action="">
<div>
<label for="number">Mask</label>
<input id="number" type="text"/>
</div>
</form>
I'm using RobinHerbots jquery input mask.
How to redefine the "9", so the mask will show XXXX91 instead of XXXXX1?
EDIT: if possible I would like to make last two digits uneditable
var autoPopulateNo = 91 //how to show the mask like this XXXX91
$("#number").inputmask({
"mask": "9999" + autoPopulateNo,
clearMaskOnLostFocus: false,
placeholder:"X",
});
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare./ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://s3-us-west-2.amazonaws./s.cdpn.io/3/jquery.inputmask.bundle.js"></script>
<form action="">
<div>
<label for="number">Mask</label>
<input id="number" type="text"/>
</div>
</form>
Share
Improve this question
edited Jun 30, 2017 at 5:03
Jeric Cruz
1,9091 gold badge15 silver badges30 bronze badges
asked Jun 30, 2017 at 2:06
RickRick
5411 gold badge9 silver badges23 bronze badges
3 Answers
Reset to default 6You can use "escapeChar"
Definition of the symbols used to escape a part in the mask.
escapeChar: "\\"
var autoPopulateNo = "\\91" //how to show the mask like this XXXX91
$("#number").inputmask({
"mask": "9999" + autoPopulateNo,
clearMaskOnLostFocus: false,
placeholder:"X",
});
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare./ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://s3-us-west-2.amazonaws./s.cdpn.io/3/jquery.inputmask.bundle.js"></script>
<form action="">
<div>
<label for="number">Mask</label>
<input id="number" type="text"/>
</div>
</form>
Use placeholder: "XXXX91"
instead of placeholder:"X"
.
If you need to escape the 9
in your mask, use \\
symbol:
$("#number").inputmask({
"mask": "9999\\91",
clearMaskOnLostFocus: false,
placeholder:"XXXX91"
});
In masked.input.min.js
file find:
translation:{
0: {
pattern: /\d/
},
"#": {
pattern: /\d/,
recursive: !0
},
A: {
pattern: /[a-zA-Z0-9]/
}
}
this part and delete:
9: {
...
}
本文标签: javascriptJquery Input Mask (Redefine numeric quot9quot)Stack Overflow
版权声明:本文标题:javascript - Jquery Input Mask (Redefine numeric "9") - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743759501a2534112.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论