我使用RobinHerbots jquery输入掩码 如何重新定义" 9",这样掩码会显示XXXX91而不是XXXXX1?
编辑:如果可能的话,我想将最后两位不可编辑
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.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/jquery.inputmask.bundle.js"></script>
<form action="">
<div>
<label for="number">Mask</label>
<input id="number" type="text"/>
</div>
</form>
&#13;
答案 0 :(得分:2)
使用placeholder: "XXXX91"
代替placeholder:"X"
。
如果您需要逃离面具中的9
,请使用\\
符号:
$("#number").inputmask({
"mask": "9999\\91",
clearMaskOnLostFocus: false,
placeholder:"XXXX91"
});
答案 1 :(得分:2)
您可以使用 "escapeChar"
用于转义蒙版中零件的符号的定义。
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.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/jquery.inputmask.bundle.js"></script>
<form action="">
<div>
<label for="number">Mask</label>
<input id="number" type="text"/>
</div>
</form>