限制只能输入小数点后两位

mac2022-06-30  99

<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

最新回复(0)