angular - 如何在一行中验证所有输入的属性?
问题描述
我想验证输入中的所有属性,但在这里不起作用
<input id="cardCode" ngModel #cardCode="ngModel" name="cardCode" type="tel" required maxlength="3" required minlength="3" class="form-control cc-cvc" required autocomplete="off">
<div style="background-color:orange;font-weight: bold;"
*ngIf="cardCode.touched && cardCode.errors?.required &&
cardCode.errors?.required" >
This is not valid CVC </div>
解决方案
尝试这个:
<div style="background-color:orange;font-weight: bold;"
*ngIf="cardCode.touched && !cardCode.valid" >
This is not valid CVC </div>
angular 基于验证器添加了一个无效的类。
推荐阅读
- mongodb - Mongo 聚合 $group _id 是一个数组
- c# - 无法从 Compilation 对象获取 SyntaxTree
- html - 不同设备中的字体更改
- javascript - Vue.js 中的 Revolution Slider jquery 插件
- google-sheets - 突出显示 Google 表格中前 x 行的列中的重复值
- odoo - 在将值设置为必填字段之前,odoo 按钮定义不起作用
- java - 从服务器肥皂故障异常中提取文本内容
- c++ - 我可以自定义一个元素是结构的流吗
- jenkins - Jenkins 只执行 groovy 闭包的第一行
- sybase - 使用 |*| 通过 BCP 加载文件 分隔符