$("#num").css({
"ime-mode" : "disabled"
}).keypress(function(e) {
if (e.which == 45) { //-
return true;
}
if (e.which == 46) { //.
var cnt = 0;
for (var m = 0; m < $(this).val().length; m++) {
if ($(this).val().charAt(m) == ".")
cnt++;
if (cnt > 0)
return false;
}
return true;
} else if ((e.which >= 48 && e.which <= 57 && e.ctrlKey == false && e.shiftKey == false) || e.which == 0 || e.which == 8) {
return true;
} else if (e.ctrlKey == true && (e.which == 99 || e.which == 118)) {
return true;
} else {
return false;
}
}).paste(function() {
if (window.clipboardData) {
var s = clipboardData.getData('text');
if (!/\D/.test(s)) {
return true;
} else {
return false;
}
} else {
return false;
}
}).dragenter(function() {
return false;
}).blur(function() {
if (self.options.fix) {
self._fixValue(target);
}
});
只允许输入数字,小数点,减号