简体   繁体   English

像ValidationGroup这样的ASP.NET使用JQuery验证插件?

[英]ASP.NET like ValidationGroup using JQuery validate plugin?

We're trying to get the JQuery validate plugin working on our site but we've stumbled across a problem here. 我们正试图让JQuery validate插件在我们的网站上运行,但我们偶然发现了一个问题。

On our site we have a login form available for the user on every page where we'd like to use the plugin to validate that the user has entered a username and password. 在我们的网站上,我们在每个页面上都有一个可供用户使用的登录表单,我们希望使用该插件来验证用户是否输入了用户名和密码。

We also have a couple of pages showing for instance some kind of form which we'd also like to validate using the validate plugin. 我们还有一些页面显示了一些我们也想使用validate插件验证的表单。

The problem we've seen is that there is no way to group the username and password textbox to the login button and all the textboxes and stuff in the other form to that form's submit-button. 我们看到的问题是没有办法将用户名和密码文本框分组到登录按钮,而将其他表单中的所有文本框和内容分组到该表单的提交按钮。 If we'd use the ASP.NET validator we'd use the ValidationGroup attribute but I haven't found a good solution for this using JQuery yet. 如果我们使用ASP.NET验证器,我们将使用ValidationGroup属性,但我还没有找到一个很好的解决方案。

http://docs.jquery.com/Plugins/Validation http://docs.jquery.com/Plugins/Validation

What you need to do is call the following code where "#myForm" is the ID of the form you're trying to validate: 您需要做的是调用以下代码,其中“#myForm”是您要验证的表单的ID:

  $(document).ready(function(){
     $("#myForm").validate();
  });

Your form would look like this: 您的表单如下所示:

     <form  id="myForm" method="get" action="">
         Name
         <input id="cname" name="name" size="25" class="required" minlength="2" />
         E-Mail
         <input id="cemail" name="email" size="25"  class="required email" />
         <input class="submit" type="submit" value="Submit"/>
     </form>

Each form you run validate() on will automatically cause validation when the submit button is clicked on it. 运行validate()的每个表单都会在单击提交按钮时自动导致验证。

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

相关问题 ASP.NET Imagebutton在ValidationGroup验证后执行jQuery功能 - ASP.NET Imagebutton Performs jQuery function after ValidationGroup Validation 需要一种更好的方法来使用jquery验证插件验证ASP.NET复选框吗? - Need a better way to validate ASP.NET checkboxes using a jquery validation plugin? 在ASP.net中使用Fancybox(jQuery插件) - Using Fancybox (jquery plugin) in ASP.net 使用jQuery在特定的“ValidationGroup”中启用/禁用asp.net验证器控件? - Enable/disable asp.net validator controls within a specific “ValidationGroup” with jQuery? 在asp.net中的RadTabStrip选项卡选择上更改RadButton的ValidationGroup - Change ValidationGroup of RadButton on RadTabStrip Tab Selection in asp.net 如何在 asp.net mvc 3 razor 中使用 jquery 验证字段 - How to validate fields using jquery in asp.net mvc 3 razor 如何使用jquery验证asp.net Web表单中的登录模式? - How to validate a login modal in asp.net webforms using jquery? 如何在 asp.net 内核中使用 jquery 验证 ckeditor? - how to validate ckeditor using jquery in asp.net core? ASP.NET LinkBut​​ton / ImageButton和JQuery验证吗? - ASP.NET LinkButton / ImageButton and JQuery Validate? 在ASP.Net中使用jQuery AutoComplete插件-自动完成时提交 - Using jQuery AutoComplete Plugin in ASP.Net - Submit on autocomplete
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM