pattern for input type=“text” with min and max number

前端 未结 3 1571
猫巷女王i
猫巷女王i 2020-12-18 04:07

how to write pattern for input type=\"text\" (it can\'t be number and the validation can\'t be with JS) that allow me to enter only numbers, min:1 and max:5000?

3条回答
  •  悲哀的现实
    2020-12-18 05:03

    Here you go - not an input with type="number" and no JS:

    
    

    The basic pattern is to match 5000 or 4-digit number or 3-digit number or 2-digit number or non-zero 1-digit number.

    If you can accept 0, the pattern can be even simpler:

    (5000|([1-4]?[0-9]?[0-9]?[0-9]?))
    

提交回复
热议问题