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