电话号码限制
<
input
type
=
"text"
id
=
"phone"
maxlength
=
"11"
onkeyup
=
"this.value=this.value.replace(/\D/g,'')"
/>
两位小数点限制的js
input 框中写法
<input clas="easyui-validatebox" type="text" name="expectMoney" onkeyup='clearNoNum(this)' />元 0.00
function clearNoNum(obj) {
obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符
obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字而不是
obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的
obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数
}