javascript - 验证并在页面上显示所有错误并在条件满足时删除错误
问题描述
我想显示我在 Aurelia 验证中应用的所有错误消息。例如,如果用户单击密码输入框,那么所有相关的错误消息都应在用户满足所需条件时逐步突出显示/显示和隐藏/删除错误。我显示你是我的模特。
"newpassword":{
"name": "newpassword",
"value": "",
"rules": [
{
"type": "isValidRegExp",
"args": [/(?=.*[a-z])/],
"msg" : "Password must contain at least 1 lowercase alphabetical character."
},
{
"type": "isValidRegExp",
"args": [/(?=.*[A-Z])/],
"msg" : "Password must contain at least 1 uppercase alphabetical character."
},
{
"type": "isValidRegExp",
"args": [/(?=.*[0-9])/],
"msg" : "Password must contain at least 1 numeric character."
},
{
"type": "isValidRegExp",
"args": [/(?=.[!@#\$%\^&])/],
"msg" : "Password must contain at least 1 special character."
},
如果用户进入密码字段,则应向用户显示模型中显示的 4 条错误消息
1- Password must contain at least 1 lowercase alphabetical character.
2- Password must contain at least 1 uppercase alphabetical character.
3- Password must contain at least 1 numeric character.
4- Password must contain at least 1 special character.
那么如果用户满足选项 1 那么选项 1 错误应该是隐藏/删除等等。
目前同时显示 1 条错误消息。
解决方案
推荐阅读
- visualization - 增加 Apache Superset 中的过滤器限制
- android - 无法从 Kotlin 中生成的 Apollo 类构建查询(.builder() 不存在)
- react-native - 使用 React-native-permissions 尝试使用 xcode ld 构建时出现此错误:找不到 -lPermission-LocationWhenInUse 的库
- node.js - Mongoose 服务器选择错误 ECONNREFUSED 与 docker-compose
- ruby - 如何使用 Shopify Plus 脚本编辑器应用程序限制产品/变体数量?
- r - 有没有办法在计算数据框中的异常值时排除 NA 但仍然在最终输出中包含 NA 行?
- html - 我在 SCSS 中的媒体查询无法正常工作
- python - Gunicorn gevent:线程中没有当前事件循环
- python - 仅将行加载到数据框中基于从非结构化格式中搜索行中的子字符串
- clojurescript - 如何在 Figwheel 中重新加载时获取更新的应用程序?