HTML5 number文本框step验证测试实例页面

回到相关文章 »

代码:

HTML代码:
<form action="" method="post">
    <p><input type="number" /><span class="description">没有step,默认无value值</span></p>
    <p><input type="number" value="1.1" /><span class="description">没有step,默认value=1.1</span></p>
    <p><input type="number" step="2.1" /><span class="description">step为2.1,默认无value值</span></p>
    <p><input type="number" step="2.1" value="2" /><span class="description">step为2.1,默认value=2</span></p>
    <p><input type="number" step="2.1" min="1" /><span class="description">step为2.1,默认无value值,min=1</span></p>
    <p><input type="number" step="0.1" value="2.00" /><span class="description">step为0.1,默认value=2.00</span></p>
    <p><input type="submit" /></p>
</form>
                

效果:

没有step,默认无value值

没有step,默认value=1.1

step为2.1,默认无value值

step为2.1,默认value=2

step为2.1,默认无value值,min=1

step为0.1,默认value=2.00