输入类型=“文本"的模式.带有最小和最大数量 [英] pattern for input type="text" with min and max number

查看:66
本文介绍了输入类型=“文本"的模式.带有最小和最大数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为输入type ="text"(它不能是数字,而验证不能使用JS)编写模式,该模式只允许我输入数字:min:1和max:5000?

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?

    <input type="text" name="someName" id="someId" required pattern=""/>

推荐答案

在这里-没有type="number"且没有JS的输入:

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

<input type="text" name="someName" id="someId" required="required"
 pattern="(5000|([1-4][0-9][0-9][0-9])|([1-9][0-9][0-9])|([1-9][0-9])|[1-9])"/>

基本模式是匹配5000或4位数字或3位数字或2位数字或非零的1位数字.

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.

如果您接受0,则模式可以更简单:

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

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

这篇关于输入类型=“文本"的模式.带有最小和最大数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆