如果表格有多个按钮,如何防止提交表格?

发布于 2025-02-10 23:03:06 字数 691 浏览 1 评论 0原文

我正在尝试提交表格,但它包含多个按钮,例如浏览文件按钮等。当我单击其他按钮时,表格正在提交。如何防止它?并仅以一个特定的按钮给出提交。

Environment Name This field is required This field requires minimum 4 characters You exceeded maximum limit KUBE Config Browse This field is required Clear Create

I am trying to submit a form, but it contains multiple button like browse file button etc.When I click other button, form is submitting.How to prevent it ?. And give submit only in one specific button.

Environment Name

This field is required

This field requires minimum 4 characters

You exceeded maximum limit

KUBE Config

Browse

This field is required

Clear

Create

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

摇划花蜜的午后 2025-02-17 23:03:06

这很简单,只需在其他按钮中添加按钮类型即可。
默认情况下,每个按钮类型都提交(键入='submit')。
因此,只需将其他按钮添加到type ='button'。仅给type ='submit ='subm'提交按钮即可。

例如:

         <button **type='button'**
                id="browse-button"
                (click)="changeReference(file_input.click())"
                mat-stroked-button
                matSuffix
              >
                Browse
           </button>

It is very simple, Just add button type to other buttons.
By default every button type is submit(type='submit').
So just add other buttons to type='button'.And only give type='submit' for submit button.

eg:

         <button **type='button'**
                id="browse-button"
                (click)="changeReference(file_input.click())"
                mat-stroked-button
                matSuffix
              >
                Browse
           </button>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文