简体   繁体   English

Angular MDL反应形式密码验证

[英]Anglular-mdl reactive forms password validation

I have a password field where I need a validation with following rules: 我有一个密码字段,需要根据以下规则进行验证:

  1. It should be alphanumeric 它应该是字母数字
  2. It should not allow only characters or numbers 它不应只允许字符或数字

      <p> <mdl-textfield label="Password" type="password" formControlName="password1" floating-label pattern="[a-zA-Z0-9]+$" error-msg="Please provide an alpha-numeric password" ></mdl-textfield> </p> 

How should I write my pattern? 我应该如何写我的图案?

One way to solve is using a pipe operator which validates to true if either of the pattern is true. 解决的一种方法是使用管道运算符,如果任一模式为true,则将其验证为true。 You could try something like this. 您可以尝试这样的事情。

([A-Za-z]+[0-9]+)|([0-9]+[A-Za-z]+)

You can read more about this here : 您可以在这里阅读更多有关此的内容:

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

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