admin管理员组文章数量:1022769
I have been using this $("#SomeId").mask("99"); jquery mask for text box where I want to enter only two digit numbers, but i do not know which mask to put in order to enable entering only one digit number and two digit. From 0-99
with mask above I cannot enter one digit number, the text box bee blank when it lose focus.
I have been using this $("#SomeId").mask("99"); jquery mask for text box where I want to enter only two digit numbers, but i do not know which mask to put in order to enable entering only one digit number and two digit. From 0-99
with mask above I cannot enter one digit number, the text box bee blank when it lose focus.
Share Improve this question edited Oct 23, 2012 at 18:36 Mathieu 4,5208 gold badges43 silver badges61 bronze badges asked Jul 21, 2009 at 12:41 EdisEdis3 Answers
Reset to default 4{mask: 9, 'maxLength': 2} should work
Edit: you have not specified what mask have you used; my answer is related to meioMask plugin.
Edit 2: for maskedinput 1.2.2:
$("#SomeId").mask("9?9");
<html>
<head>
<script src="http://code.jquery./jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#test').keypress(allowOnlyTwoPositiveDigts);
});
function allowOnlyTwoPositiveDigts(e){
var test = /^[\-]?[0-9]{1,2}?$/
return test.test(this.value+String.fromCharCode(e.which))
}
</script>
</head>
<body>
<input id="test" type="text" />
</body>
</html>
<input id="id_input" class=".class_input" type="text" />
$('#id_input').mask('99');
$('.class_input').mask('99');
I have been using this $("#SomeId").mask("99"); jquery mask for text box where I want to enter only two digit numbers, but i do not know which mask to put in order to enable entering only one digit number and two digit. From 0-99
with mask above I cannot enter one digit number, the text box bee blank when it lose focus.
I have been using this $("#SomeId").mask("99"); jquery mask for text box where I want to enter only two digit numbers, but i do not know which mask to put in order to enable entering only one digit number and two digit. From 0-99
with mask above I cannot enter one digit number, the text box bee blank when it lose focus.
Share Improve this question edited Oct 23, 2012 at 18:36 Mathieu 4,5208 gold badges43 silver badges61 bronze badges asked Jul 21, 2009 at 12:41 EdisEdis3 Answers
Reset to default 4{mask: 9, 'maxLength': 2} should work
Edit: you have not specified what mask have you used; my answer is related to meioMask plugin.
Edit 2: for maskedinput 1.2.2:
$("#SomeId").mask("9?9");
<html>
<head>
<script src="http://code.jquery./jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#test').keypress(allowOnlyTwoPositiveDigts);
});
function allowOnlyTwoPositiveDigts(e){
var test = /^[\-]?[0-9]{1,2}?$/
return test.test(this.value+String.fromCharCode(e.which))
}
</script>
</head>
<body>
<input id="test" type="text" />
</body>
</html>
<input id="id_input" class=".class_input" type="text" />
$('#id_input').mask('99');
$('.class_input').mask('99');
本文标签: javascriptmask for one digit and two digitStack Overflow
版权声明:本文标题:javascript - mask for one digit and two digit - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745574496a2156934.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论