简体   繁体   English

如何禁用按钮提交表单

[英]How can i disable button from submitting the form

I have a kendo Grid inside a form, in the grid i have Edit Button to display Edit Popup window, but when i click on it submits the form to a controller, Is there anyway to prevent from submitting the form?我在表单中有一个剑道网格,在网格中我有一个编辑按钮来显示编辑弹出窗口 window,但是当我点击它时,它会将表单提交给 controller,有什么办法阻止提交表单吗?

<button class="btn btn-link" onkeydown="editGridRow(&quot;AddressGrid&quot;, this)" onclick="editGridRow(&quot;AddressGrid&quot;, this)">Edit</button>

I also have another button to save the changes made, i only want to submit the form when Save button below clicked我还有另一个按钮来保存所做的更改,我只想在单击下面的保存按钮时提交表单

<button type="submit" class="btn btn-success" role="button"><i class="fas fa-save"></i>&nbsp; &nbsp;Save</button>

so when you click on submit button, a default action happens that is to submit the form因此,当您单击提交按钮时,会发生默认操作,即提交表单

so to prevent that default action from happening you use a function called preventDefault因此,为了防止发生默认操作,您使用名为preventDefault的 function

read a simple solution here https://www.sitepoint.com/community/t/how-to-set-up-preventdefault-on-form-submit/245580在这里阅读一个简单的解决方案https://www.sitepoint.com/community/t/how-to-set-up-preventdefault-on-form-submit/245580

read about preventDefault here: https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault在此处阅读有关 preventDefault 的信息: https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault

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

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