Copy Code code as follows:
$ (function () {
Text boxes can only enter numbers (excluding decimals) and screen input and paste
$.fn.integer= function () {
$ (this). CSS ("Ime-mode", "disabled");
This.bind ("KeyPress", function (e) {
var code = (E.keycode E.keycode:e.which); Compatible with Firefox IE
if (!$.browser.msie&& (e.keycode==0x8)) {//Firefox can not use the BACKSPACE key
return;
}
Return code >= && code<= 57;
});
This.bind ("Paste", function () {
return false;
});
This.bind ("KeyUp", function () {
if (/(^0+)/.test (this.value)) {
This.value = This.value.replace (/^0*/, ");
}
});
};
Text boxes can only enter numbers (including decimals) and screen input and paste
$.fn.number= function () {
$ (this). CSS ("Ime-mode", "disabled");
This.bind ("KeyPress", function (e) {
var code = (E.keycode E.keycode:e.which); Compatible with Firefox IE
if (!$.browser.msie&& (e.keycode==0x8)) {//Firefox can not use the BACKSPACE key
return;
}
if (This.value.indexOf (".") ==-1) {
Return (Code >= && code<= 57) | | (code==46);
}else{
Return code >= && code<= 57
}
});
This.bind ("Paste", function () {
return false;
});
This.bind ("KeyUp", function () {
if (this.value.slice (0,1) = = ".") {
This.value = "";
}
});
This.bind ("Blur", function () {
if (This.value.slice (-1) = = ".") {
This.value = This.value.slice (0,this.value.length-1);
}
});
};
});