Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试自动格式化输入标签以显示小数位。我首先认为也许我应该使用 Javascript,但经过一些研究,我发现它可以使用 html5 来完成,特别是使用pattern属性。有人告诉我,您可以在其中分配一个正则表达式,但我找不到。
这是我的输入标签
<input type='text' name='amount' id='amount'/>
you could use the 'number' type
<style> input:valid +p { display:none } input:invalid +p { display:block } </style> <form> <input type="number" min="0.5" max="3.14" step="0.01" required ></input> <p>Must be provided and be a decimal.</p> </form>