角材料输入模式添加空白

时间:2019-03-19 11:12:03

标签: javascript regex angular

我在验证角度7输入模式中的空白时遇到问题。

<form #f="ngForm">
    <mat-form-field floatLabel="always">
        <input type="text" pattern="[a-zA-Z0-9_-\s]+" required matInput name="folderName">
    </mat-form-field>
    </form>
<button mat-raised-button [disabled]="!f.valid">Create</button>

我尝试过:

  • pattern =“ [a-zA-Z0-9 _- \ s] +”创建按钮在我第一次添加空间时被禁用
  • pattern =“ [a-zA-Z0-9_-] +”我从angular收到消息“无效的正则表达式”。这是模式中'-'后面的空白,无效。

我错了吗?

0 个答案:

没有答案
相关问题