日期:2014-05-16 浏览次数:20448 次
<input onkeypress = "return event.keyCode>=48&&event.keyCode<=57||event.keyCode==46" onpaste = "return !clipboardData.getData('text').match(/\D/)" ondragenter = "return false" style = "ime-mode:Disabled" />
<script type ="text/javascript " > /*只能输入数字和点,可按退格键删除数字或点*/ function vaildFloatNumber(evnt){ evnt=evnt||window.event; var keyCode=window.event?evnt.keyCode:evnt.which; return keyCode>=48&&keyCode<=57||keyCode==46||keyCode==8; } /*只能输入数字,可按退格键删除数字*/ function vaildIntegerNumber(evnt){ evnt=evnt||window.event; var keyCode=window.event?evnt.keyCode:evnt.which; return keyCode>=48&&keyCode<=57||keyCode==8; } <input onkeypress = "return vaildFloatNumber(event) " onpaste = "return !clipboardData.getData('text').match(/\D/) " ondragenter = "return false " style = "ime-mode:Disabled " /> <input onkeypress = "return vaildIntegerNumber(event) " onpaste = "return !clipboardData.getData('text').match(/\D/) " ondragenter = "return false " style = "ime-mode:Disabled " /> </script>
<input onkeyup ="this . value=this.value.replace(/\D/g,'') " onafterpaste ="this.value=this .value.replace(/\D/g,'') " />