<script type="text/javascript"> function strNumber(elm){ elm.value = elm.value.replace(/^[^0-9.]*(\d*[\.]?\d{0,2})\w*$/,'$1'); }</script>
<input type="text" οnkeyup="strNumber(this)"/>
转载于:https://www.cnblogs.com/txhy/p/4901395.html