only input number & dot

<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
js Ö»ÄÜÊäÈëÊý×ÖºÍСÊýµã
<script language="JavaScript" type="text/javascript">
?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("$#$",".");
?}
?</script>
</head>
<body>
<!---->
Ö»ÄÜÊäÈëÊý×ÖºÍСÊýµãµÄÎı¾¿ò£º

Ö»ÄÜÊäÈëÊý×ÖºÍСÊýµãµÄÎı¾¿ò£º
</body>
</html>

你可能感兴趣的:(JavaScript,html)