![](/img/trans.png)
[英]html <input type=“text” /> number-only with min and max value
[英]pattern for input type=“text” with min and max number and with conditional
如何为输入type="text"
(不能为数字,验证不能为JS)编写模式,该模式只允许我输入数字:min:1和max:30? 有条件的:
<input type="checkbox" id="Checkbox" name="Checkbox" [attr.pattern]="selectedField === 'calendar' ?([1-9]|[12]\d|3[01]): false" [(ngModel)]="periodicObj[0].ischecked" (change)="OnChange($event,0)">
所以基本上基于selectedField我需要验证我的输入字段
尝试这个
<input type="text" name="someName" id="someId" required="required" pattern="(30|([1-2][0-9])|[1-9])"/>
您为什么不使用输入type="number
”来处理min
和max
<input type="number" min="1" max="30" />
如果没有javascript
,您将如何validate
value
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.