简体   繁体   中英

Input type number decimal not accepting in Firefox

 input[type='number'] { -moz-appearance: textfield !important; } .no-spin::-webkit-inner-spin-button, .no-spin::-webkit-outer-spin-button { -webkit-appearance: none !important; margin: 0 !important; } .input::-webkit-inner-spin-button, .input::-webkit-outer-spin-button { -webkit-appearance: none !important; margin: 0 !important; } 
 <input type="number" oninput="this.value = this.value.replace(/[^0-9.]/g,'')" lang="en"> 

I am unable to get Firefox 60.0.2 to accept period (.) to enter decimal number. But the same is working in chrome. This does not work even with style removed.

How to write proper html input tag with either text or number type but preferably number type so decimal input is accepted

为什么不只使用type = text,因为您已经有了只允许小数的脚本?

 <input type="text" oninput="this.value = this.value.replace(/[^0-9\\.]/g, '').split(/\\./).slice(0, 2).join('.')" lang="en"> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM