| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> |
| 5 |
<title>jQuery validation plug-in - comment form example</title> |
| 6 |
|
| 7 |
<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" /> |
| 8 |
|
| 9 |
<script src="../lib/jquery.js" type="text/javascript"></script> |
| 10 |
<script src="../jquery.validate.js" type="text/javascript"></script> |
| 11 |
<script src="../lib/jquery.metadata.js" type="text/javascript"></script> |
| 12 |
|
| 13 |
<!-- for styling the form --> |
| 14 |
<script src="js/cmxforms.js" type="text/javascript"></script> |
| 15 |
|
| 16 |
<script type="text/javascript"> |
| 17 |
$(document).ready(function() { |
| 18 |
$("#commentForm").validate({meta: "validate"}); |
| 19 |
$("#commentForm2").validate(); |
| 20 |
$("#commentForm3").validate({ |
| 21 |
messages: { |
| 22 |
email: { |
| 23 |
required: 'Enter this!' |
| 24 |
} |
| 25 |
} |
| 26 |
}); |
| 27 |
|
| 28 |
}); |
| 29 |
</script> |
| 30 |
|
| 31 |
<style type="text/css"> |
| 32 |
form { width: 500px; } |
| 33 |
form label { width: 250px; } |
| 34 |
form label.error, |
| 35 |
form input.submit { margin-left: 253px; } |
| 36 |
</style> |
| 37 |
|
| 38 |
</head> |
| 39 |
<body> |
| 40 |
|
| 41 |
<h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">jQuery Validation Plugin</a> Demo</h1> |
| 42 |
<div id="main"> |
| 43 |
|
| 44 |
<p>Take a look at the source to see how messages can be customized with metadata.</p> |
| 45 |
|
| 46 |
<!-- Custom messages with custom "meta" setting --> |
| 47 |
<form class="cmxform" id="commentForm" method="post" action=""> |
| 48 |
<fieldset> |
| 49 |
<legend>Please enter your email address</legend> |
| 50 |
<p> |
| 51 |
|
| 52 |
<label for="cemail">E-Mail *</label> |
| 53 |
<input id="cemail" name="email" class="{validate:{required:true, email:true, messages:{required:'Please enter your email address', email:'Please enter a valid email address'}}}"/> |
| 54 |
</p> |
| 55 |
<p> |
| 56 |
<input class="submit" type="submit" value="Submit"/> |
| 57 |
</p> |
| 58 |
</fieldset> |
| 59 |
</form> |
| 60 |
<!-- Custom messages with default "meta" setting --> |
| 61 |
<form class="cmxform" id="commentForm2" method="post" action=""> |
| 62 |
<fieldset> |
| 63 |
<legend>Please enter your email address</legend> |
| 64 |
<p> |
| 65 |
|
| 66 |
<label for="cemail">E-Mail *</label> |
| 67 |
<input id="cemail" name="email" class="{required:true, email:true, messages:{required:'Please enter your email address', email:'Please enter a valid email address'}}"/> |
| 68 |
</p> |
| 69 |
<p> |
| 70 |
<input class="submit" type="submit" value="Submit"/> |
| 71 |
</p> |
| 72 |
</fieldset> |
| 73 |
</form> |
| 74 |
<!-- Custom message for "required" in metadata is overriden by a validate option --> |
| 75 |
<form class="cmxform" id="commentForm3" method="post" action=""> |
| 76 |
<fieldset> |
| 77 |
<legend>Please enter your email address</legend> |
| 78 |
<p> |
| 79 |
|
| 80 |
<label for="cemail">E-Mail *</label> |
| 81 |
<input id="cemail" name="email" class="{required:true, email:true, messages:{email:'Please enter a valid email address'}}"/> |
| 82 |
</p> |
| 83 |
<p> |
| 84 |
<input class="submit" type="submit" value="Submit"/> |
| 85 |
</p> |
| 86 |
</fieldset> |
| 87 |
</form> |
| 88 |
|
| 89 |
<a href="index.html">Back to main page</a> |
| 90 |
|
| 91 |
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script> |
| 92 |
<script type="text/javascript">_uacct = "UA-2623402-1";urchinTracker();</script> |
| 93 |
|
| 94 |
</body> |
| 95 |
</html> |