简体   繁体   English

具有输入属性“必需”和“模式”的表单不起作用

[英]form with input attributes 'required' and 'pattern' doesn't work

Hi i have this code with HTML5:嗨,我有 HTML5 的代码:

<form id="pay" method="GET" class="row g-3" style="display:none;" type="hidden">
  <strong>Date</strong></a><br>
  <div class="col-md-10">
    <label for="name_users_card" class="form-label">user card</label>
    <input type="text" class="form-control" id="name_users_card"
           pattern="^[A-Za-zèòà\s]$"
           minlength="3"
           maxlength="20"
           placeholder="titolare carta"
           title="take a valid name" required/>
  </div>
</form>

When I try to run the code, the required control is not working.当我尝试运行代码时,所需的控件不起作用。 Why?为什么?

don't actually understand the problem but you have an incomplete <a> tag and you made your form hidden by setting display:none;并不真正理解这个问题,但你有一个不完整的<a>标签,你通过设置display:none;

Your Regular Expression Pattern :您的正则表达式模式

^[A-Za-zèòà\s]$

is a single character .单个字符

If you want zero to any number of characters , use:如果您想要零到任意数量的字符,请使用:

^[A-Za-zèòà\s]*$

If you want one to any number of characters , use:如果您想要一个到任意数量的字符,请使用:

^[A-Za-zèòà\s]+$

If you want exactly twenty characters , use:如果您想要正好 20 个字符,请使用:

^[A-Za-zèòà\s]{20}$

If you want three to twenty characters , use:如果您想要三到二十个字符,请使用:

^[A-Za-zèòà\s]{3,20}$

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM