在触发取消按钮之前激活了角形验证

编程入门 行业动态 更新时间:2024-10-28 03:31:44
本文介绍了在触发取消按钮之前激活了角形验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试在模式对话框中创建一个带有验证的小表格. 该对话框具有一个取消按钮,该按钮应隐藏该对话框:

I am trying to create a little form with validation inside a modal dialog. The dialog has a cancel button which should hide the dialog:

我创建了一个小项目来验证它:

I've created a small project to verify it:

embed.plnkr.co/jF202JGxI0f7BjeKhL7A/

名称字段具有一个验证,如果该名称保留为空,则会触发该验证.显示对话框时,输入字段将成为焦点.

The name field has a validation which is triggered if the name is left empty. The input field gets focus when the dialog is shown.

问题是现在按下取消而不输入任何文本.

The problem is now pressing cancel without entering any text.

在触发按钮的单击处理程序之前,将启动验证.结果是显示错误消息.这会将取消按钮下移,然后单击进入必杀技.

The validation kicks in before the button's click handler is triggered. The result is that the error message is displayed. This moves the cancel button down and the click goes to nirvana.

您可以通过单击取消按钮的顶部来验证此行为. 如果单击底部,一切都会按预期进行(除了我不希望完全不显示验证消息).

You can verify this behavior by clicking the top part of the cancel button. If you click the bottom part everything works as expected (except that I would prefer not to show the validation message at all).

所以...我想要拥有的东西:

So... what I'd like to have:

如果用户则触发验证

  • 通过按Tab键离开字段
  • 单击下一个字段(在其他具有更多字段的对话框中)
  • 点击确定/创建指标
  • 更改字段内容

如果用户未触发,则不会触发

Trigger no validation if user

  • 点击取消"
  • 在对话框外单击
推荐答案

我遇到了同样的问题.我在cancel按钮上所做的解决方法是,使用(mousedown)而不是(click)消除模型.

I have faced same issue. The workaround I made on cancel button is, use (mousedown) instead of (click) to dismiss the model.

更多推荐

在触发取消按钮之前激活了角形验证

本文发布于:2023-11-26 15:07:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634222.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:角形   按钮

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!