验证没有表单标签的字段、选择或复选框
美好的一天,
我发现了很多与此相关的主题,但是没有正确的答案。
许多主题都以问题结束,为什么你不能添加表单?
我正在开发一个基于 ASP.NET 的项目,我有一个表单标签,一个包含其中所有 html 代码的表单标签。
我无法使用任何 ASP.NET 控件,必须通过前端 (jQuery) 进行验证。
当只有一个表单和一个提交按钮时,一切都很好,然后我可以使用简单的查询验证插件,但当我有多个表单,当然还有多个提交按钮时,它会变得复杂。
例如:
<html>
<head></head>
<body>
<form method="post" action="" id="form123">
<div id="wrapper">
<div id="form1">
<input id="field1 "type="text" />
<input id="submit1" type="submit" value="submit" />
</div>
<div id="form2">
<input id="field2" type="text" />
<input id="submit2" type="submit" value="submit" />
</div>
</div>
<form>
</body>
</html>
有什么建议、想法或真实的例子吗?
也许我可以以某种方式将每个字段和提交按钮放入 div 中,并通过在该 div 中提交来验证它们?
谢谢你!
Good day,
I found a lot of topics about that, but, without a proper answer.
Many of topics ended with question why you just can't add form?
I'm working on a project that based on ASP.NET and I have one form tag, one form tag that contains all the html code inside it.
I can't use any ASP.NET controls and must done validation by front-end (jQuery).
Everything is fine when there is only one form and one submit button, then I can use simple query validation plugin, but it gets complicated when I have more than one form and of course more than one submit button.
For example:
<html>
<head></head>
<body>
<form method="post" action="" id="form123">
<div id="wrapper">
<div id="form1">
<input id="field1 "type="text" />
<input id="submit1" type="submit" value="submit" />
</div>
<div id="form2">
<input id="field2" type="text" />
<input id="submit2" type="submit" value="submit" />
</div>
</div>
<form>
</body>
</html>
Any suggestion, ideas or real example how to do that?
Maybe I can somehow put every field and submit button inside a div and validate them by submit within that div?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对需要单独验证的元素使用特定的类或 ID。
所以它最终会看起来像这样:
然后使用任何你的验证插件你可以做这样的事情:
并做有条件的事情,等等
use specific classes or ids on the elements you need to validate separately.
so it will end up looking something like:
and then using whatever your validation plugin you can do things like:
and do conditional things, etc etc