$(function(){
/*JQuery restricts the text box to only enter numbers*/
$(".NumDecValue").keyup(function(){
$(this).val($(this).val().replace( /[^\d]/g,''));
}).bind("paste",function(){ //CTR+V event handling
$(this).val($(this).val(). replace(/[^\d]/g,''));
}).css("ime-mode", "disabled"); //CSS sets the input method to be unavailable
/*JQuery restricts the text box to only enter numbers and decimal point */
$(".NumDecText").keyup(function(){
$(this).val($(this).val().replace(/[^0-9.]/g,'') );
}).bind("paste",function(){ //CTR+V event processing
$(this).val($(this).val().replace(/[^0-9.]/g ,''));
}).css(" ime-mode", "disabled"); //CSS setting input method unavailable
/*JQuery restricts the text box to only enter numbers and 2 decimal places*/
$(".
NumDecTextTwo
").keyup(function(){
$(this).val((this.value.match(/\d+(\ .\d{0,2})?/)||[''])[0]);
}).bind("paste",function(){ //CTR+V event handling
$(this).val ((this.value.match(/\d+(\.\d{0,2})?/)||[''])[0]);
}).css("ime-mode", "disabled "); //CSS set input method unavailable
});
Example of usage:
<input type="text" name="expenses" id="expenses" class="
NumDecTextTwo
" placeholder="accurate to 2 decimal places" />
Follow-up supplement. . . .
Js/Jquery limit text box input method
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326947520&siteId=291194637
Recommended
Ranking