只能输入数字和小数点(一个小数点)

来源:互联网 发布:端口有感叹号 编辑:程序博客网 时间:2024/05/16 17:20
<html><head><title>只能输入数字和小数</title><script>function onKeyUpDesc(text){var value = text.value; if (isNaN(value) && value != "." ){ value = value.substring(0,value.length-1); text.value = value ;}}</script></head><body><input type="text" oninput="onKeyUpDesc(this)" onpropertychange="onKeyUpDesc(this)"></body></html>


可以输入多个点的(如IP地址,请关注下篇)

转载请注明出处。

0 0