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("$#$",".");
}
<input id="openDuringTime" name="openDuringTime" size="10" οnkeyup="clearNoNum(this)"></input>
{
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("$#$",".");
}
<input id="openDuringTime" name="openDuringTime" size="10" οnkeyup="clearNoNum(this)"></input>