Created
August 22, 2012 07:51
-
-
Save xnnyygn/3423567 to your computer and use it in GitHub Desktop.
Test html for validation two form with same class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-latest.js"></script> | |
<script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script> | |
<style type="text/css"> | |
* { font-family: Verdana; font-size: 96%; } | |
label { width: 10em; float: left; } | |
label.error { float: none; color: red; padding-left: .5em; vertical-align: top; } | |
p { clear: both; } | |
.submit { margin-left: 12em; } | |
em { font-weight: bold; padding-right: 1em; vertical-align: top; } | |
</style> | |
<script> | |
$(document).ready(function(){ | |
// this works OK | |
$("#commentForm1").validate(); | |
$("#commentForm2").validate(); | |
// when I click the second submit, the first form was validated! | |
//$(".cmxform").validate(); | |
}); | |
</script> | |
</head> | |
<body> | |
<form class="cmxform" id="commentForm1" method="get" action=""> | |
<fieldset> | |
<legend>A simple comment form with submit validation and default messages</legend> | |
<p> | |
<label for="cname">Name</label> | |
<em>*</em><input id="cname" name="name" size="25" class="required" minlength="2" /> | |
</p> | |
<p> | |
<label for="cemail">E-Mail</label> | |
<em>*</em><input id="cemail" name="email" size="25" class="required email" /> | |
</p> | |
<p> | |
<label for="curl">URL</label> | |
<em> </em><input id="curl" name="url" size="25" class="url" value="" /> | |
</p> | |
<p> | |
<label for="ccomment">Your comment</label> | |
<em>*</em><textarea id="ccomment" name="comment" cols="22" class="required"></textarea> | |
</p> | |
<p> | |
<input class="submit" type="submit" value="Submit"/> | |
</p> | |
</fieldset> | |
</form> | |
<form class="cmxform" id="commentForm2" method="get" action=""> | |
<fieldset> | |
<legend>A simple comment form with submit validation and default messages</legend> | |
<p> | |
<label for="cname">Name</label> | |
<em>*</em><input id="cname" name="name" size="25" class="required" minlength="2" /> | |
</p> | |
<p> | |
<label for="cemail">E-Mail</label> | |
<em>*</em><input id="cemail" name="email" size="25" class="required email" /> | |
</p> | |
<p> | |
<label for="curl">URL</label> | |
<em> </em><input id="curl" name="url" size="25" class="url" value="" /> | |
</p> | |
<p> | |
<label for="ccomment">Your comment</label> | |
<em>*</em><textarea id="ccomment" name="comment" cols="22" class="required"></textarea> | |
</p> | |
<p> | |
<input class="submit" type="submit" value="Submit"/> | |
</p> | |
</fieldset> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment