input输入框 只能输入 数字可以有小数点
<input class="form_text" id="purchasePrice" name="purchasePrice" value="" onkeyup="value=value.replace(/[^d.]/g,'')"
dataType="/^-?[1-9]+(.d+)?$|^-?0(.d+)?$|^-?[1-9]+[0-9]*(.d+)?$/" errormsg="必须为数字,可以有小数" msg="此项为必填" />
或者写成
<input class="form_text" id="purchasePrice" name="purchasePrice" value="" onkeyup="checkValue(this)"
dataType="/^-?[1-9]+(.d+)?$|^-?0(.d+)?$|^-?[1-9]+[0-9]*(.d+)?$/" errormsg="必须为数字,可以有小数" msg="此项为必填" />
function checkValue(obj)
{
var objVal = $(obj).val();
$(obj).val(objVal.replace(/[^d.]/g,''));
}