Skip to content

Commit 5d5587b

Browse files
author
bbraithwaite
committed
Updated readme
1 parent d116212 commit 5d5587b

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

README

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#JQuery Validation Groups for WebForms
2+
3+
A plug-in that takes the pain out of using JQuery validation with ASP.Net WebForms.
4+
5+
Enables "validation groups" using JQuery Validation with ASP.Net WebForms.
6+
7+
For more information please see [blog post] (http://www.contentedcoder.com/2012/08/jquery-validation-groups-for-webforms.html).
8+
9+
**Get Started**
10+
11+
Replace the validate bind the validate event from:
12+
13+
```javascript
14+
$("#aspForm").validate();
15+
```
16+
17+
To:
18+
19+
```javascript
20+
$("#aspForm").validateWebForm();
21+
```
22+
23+
To create a validation group, add the class "form" to the containing element. Add the class "submit" to the element that should validate upon submit. Now these will be validated seperately, even though they are within the same form:
24+
25+
```xml
26+
<fieldset class="form" id="signup">
27+
<asp:Textbox ID="uxUsername" runat="server" CssClass="required" />
28+
<asp:Button ID="uxRegister" runat="server" Text="Sign Up" CssClass="submit" />
29+
</fieldset>
30+
```
31+
32+
That's it!
33+
34+
**FULL EXAMPLE**
35+
36+
```xml
37+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
38+
<html xmlns="http://www.w3.org/1999/xhtml">
39+
<head id="Head1" runat="server">
40+
<title>Multiple Form Validation</title>
41+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
42+
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
43+
<script type="text/javascript" src="jquery.validation.net.webforms.js"></script>
44+
<script type="text/javascript">
45+
$(function() {
46+
$("#aspForm").validateWebForm();
47+
});
48+
</script>
49+
</head>
50+
<body>
51+
<form id="aspForm" runat="server">
52+
<fieldset class="form" id="signup">
53+
<legend>Sign Up</legend>
54+
<p>
55+
<asp:Label ID="uiFirstName" runat="server" AssociatedControlID="uxFirstName" Text="First name:"></asp:Label>
56+
<asp:TextBox ID="uxFirstName" runat="server" CssClass="required"></asp:TextBox>
57+
</p>
58+
<p>
59+
<asp:Button ID="uxRegister" runat="server" Text="Sign Up" CssClass="submit signup" />
60+
<asp:Button ID="uxCancelRegister" runat="server" Text="Cancel" />
61+
</p>
62+
</fieldset>
63+
<fieldset class="form" id="login">
64+
<legend>Login</legend>
65+
<p>
66+
<asp:Label ID="uiUserName" runat="server" AssociatedControlID="uxUserName" Text="User name:"></asp:Label>
67+
<asp:TextBox ID="uxUserName" runat="server" CssClass="required email"></asp:TextBox>
68+
</p>
69+
<p>
70+
<asp:Button ID="uxLogin" runat="server" Text="Login" CssClass="submit login" />
71+
<asp:Button ID="uxCancelSignUp" runat="server" Text="Cancel" />
72+
</p>
73+
</fieldset>
74+
</form>
75+
</body>
76+
</html>
77+
```
78+
79+
**Feedback**
80+
81+
This plug-in is being actively maintained. If you see an issue please flag it either vai the blog post or by raising an issue via Github.

0 commit comments

Comments
 (0)