js限制输入框只能输入两位小数点

 通过onimput事件和正则实现

<input
    type="number"
    oninput="value=value.toString().match(/^\d+(?:\.\d{0,2})?/)">

猜你喜欢

转载自blog.csdn.net/joyvonlee/article/details/106998839