jQuery.inputmask text
Test the jQuery.inputmask plugin
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/3.3.3/jquery.inputmask.bundle.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.alphanum/1.0.24/jquery.alphanum.min.js"></script>
<label>integer</label>
<input type="text" value='30' id="age">
</br>
<label>mask greedy</label>
<input type="text" value='0' id="g">
</br>
<label>decimal</label>
<input type="text" class="move" id="ht">
</br>
<label>integer min/max</label>
<input type="text" class="number" value='0' id="mm">
</br>
<label>max length</label>
<input id="mx2">
JavaScript
/*
$('#age').inputmask(
'integer', {
autoUnmask: true,
rightAlign: false,
min: 18,
max: 80,
prefix: '',
suffix: ' %',
});
$("#g").inputmask({
"mask": "9",
"repeat": 1,
"greedy": true
});
$('input[type=text].move').inputmask(
'decimal', {
//digits: 5,
//greedy: false,
allowMinus: false
//min: -10000,
//max: 10000
});
$(".number").inputmask("integer", {
step: 1,
min: 0,
max: 99999
});
$(function(){
$("#mx2").alpha();
});
*/
/* */
$(function(){
$("#mx2").on('change keydown keyup', function(eventObject){
//alert($(this).text());
//if(!$(this).length <= 4){
if ($(this).val().length > 4) {
$(this).val($(this).val().substr(0,4));
}
});
});