1
所以,我有我的常规文本框,但我似乎无法找到接受字母数字值的蒙版。JQuery MVC - 接受字母和数字的蒙面文本框
HTML:
<div class="form-group">
<div class="col-md-6">
<label class="control-label">Security code:</label>
@Html.TextBox("txtSecCode", null, new { @class = "form-control", maxlength = 20 })
</div>
</div>
的Javascript:(顺便说一句,我使用的Razer引擎视图)
<script type="text/javascript">
$(function() {
$('#txtSecCode').keyup(function() {
// I used this to not let the user input any special characters.
if (this.value.match(/[^a-zA-Z0-9 ]/g)) {
this.value = this.value.replace(/[^a-zA-Z0-9 ]/g, '');
}
});
// The 'blur' function is used to auto-mask the field when it's not focused
$('#txtSecCode').blur(function() {
// So that's my mask, at first my field's maxlength was set to
// 16, but than some errors occured and then I realized that the
// dots(.) of the mask were the guilt for this.
$('#txtSecCode').mask('9999.9999.9999.9999');
});
});
</script>
不管怎么说,口罩应接受像值:“98AC。 981X.B8TZ.EW89'。 如果有人知道可以输入字母数字值的文本框字段掩码,请告诉我。
在此先感谢:d