婷婷同学_
js方法:validationNumber(e, num) e代表标签对象,num代表保留小数位数function validationNumber(e, num) {var regu = /^[0-9]+.?[0-9]*$/;if (e.value != "") {if (!regu.test(e.value)) {alert("请输入正确的数字");e.value = e.value.substring(0, e.value.length - 1);e.focus();} else {if (num == 0) {if (e.value.indexOf('.') > -1) {e.value = e.value.substring(0, e.value.length - 1);e.focus();}}if (e.value.indexOf('.') > -1) {if (e.value.split('.')[1].length > num) {e.value = e.value.substring(0, e.value.length - 1);e.focus();}} }
}
}
保留两位小数CssClass="EditTextBox" onpropertychange="validationNumber(this,2)">/asp:TextBox