js 正則取整正數(shù),或浮點數(shù)且保留兩位小數(shù),去除字符串中的非數(shù)字
正則校驗
/^[0-9]+(.[0-9]{1,2})?$/.test(value)
//正整數(shù)
'qwerqwe.1.2.3.qwerqwerq'.replace(/[^0-9]*/g,"") //1.2
//正則取代,禁止輸入其他
'qwerqwe.1.2.3.qwerqwerq'.replace(/^\D*([0-9]\d*\.?\d{0,2})?.*$/,'$1') // 123