HTML5 input number min max not working with required

后端 未结 3 764
花落未央
花落未央 2020-12-11 17:04

I would like to force the user to type their age. I also would like to make sure they only enter between 18-99. Is that possible with HTML5 attributes like

相关标签:
3条回答
  • 2020-12-11 17:36

    Your code works fine. Check this fiddle (I'm using latest chrome)

    My only concern you is your pattern="[1-8][0-9]" can simple use this

    pattern="[0-9]{2}"
    
    0 讨论(0)
  • 2020-12-11 17:41

    It doesn't work in Firefox but it works in Chrome, Internet Explorer, Safari and Opera.

    Please find the working demo here: Demo

    <form action="">
    
    <input type="number" name="points" min="1" max="10" name="Q2age" id="Q2age" required>
    
     <input type="submit" value="submit" />
    </form>
    
    0 讨论(0)
  • 2020-12-11 17:51

    This is the expected behaviour because FF21 doesnt supports min,max attribute...

    you can check it in http://html5test.com/

    Check the screenshot enter image description here

    0 讨论(0)
提交回复
热议问题