gpt4 book ai didi

c# - ASP.Net Core 客户端验证 : is there a "validation succeeded" DOM event?

转载 作者:行者123 更新时间:2023-12-03 20:46:01 25 4
gpt4 key购买 nike

我有一个使用 Bootstrap 并进行客户端验证的 ASP.Net Core Razor 页面。
表格如下所示:

<form method="post" class="needs-validation" novalidate>
...
_ValidationScriptsPartial.cshtml 如下所示:
<environment include="Development">
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
...
一切正常。如果用户未能输入必填字段或输入的数字超过最大值,则表单将不会提交,并且违规字段以红色突出显示。
问:是否有“验证成功”触发的 DOM 事件?
我想在我知道表单“OK”之后执行一些 Javascript,但在它实际发布到服务器之前。
先感谢您!

最佳答案

如果你想要一个 快速交 key 解决方案 ,您可以简单地包含 jQuery Validation Plugin .有效条件仅在其有效时才返回真。

Answer: you can then rxJs-subscribe to it by sending the data structure or the control in to get the event out using this jquery.observable plugin


以下是 Jquery Valid 的工作原理:
形式:
$("form").valid(); 
// or
if($("form").valid()) {
//VALID continue
}

控制:
$("[name='CountyOfBirth']").valid(); // RETURNS true/false

On Submit:您还可以通过检查表单提交来获得与有效事件类似的结果
$("form").submit(function() {
if($(this).valid()) {
//VALID
} else {
//ERROR
}
});

关于c# - ASP.Net Core 客户端验证 : is there a "validation succeeded" DOM event?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65586221/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com