function $(o) { return document.getElementById(o) }
$('test').onblur = function() {
debugger;
var re = /^\d+(\.\d)?$/;
var bol = re.test(this.value);
if (bol == true) {
}
else {
alert("123");
}
}
他是空也是flase...直接弹出123...能不能在他是数字和小数和空的情况下是true.....谢谢了
function $(o) { return document.getElementById(o) } $('test').onblur = function() { debugger; var re = /^\d+(\.\d)?$/; var bol = re.test(this.value); if (bol == true) { } else if(this.value !== ""){ alert("123"); } }
加了一个为空的判断
谢谢了噢!
^([+-])?\d*(\.\d+)?$