Js 小数验证函数代码(基于正则)


(1)OnKeyPress 事件验证 用来验证输入操作

复制代码 代码如下:

function OnKeyPressValidate(obj, event, len) {
var e = window.event || event;
var key = e.keyCode ? e.keyCode : e.which;
var selectedText = "";
if (window.getSelection) {
var st = obj.selectionStart;
var ed = obj.selectionEnd;
selectedText = obj.value.substring(st, ed);
} else if (document.selection) {
selectedText = document.selection.crea