I am using Jq开发者_如何转开发uery validation plugin to validate my form at client side. I need to know what showError function does. It takes two parameters errorMap and errorList, what are these parameters.
Just to show error message. e.g:
<!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://dev.jquery.com/view/trunk/plugins/validate/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(){
$("#commentForm").validate();
});
</script>
</head>
<body>
<form class="cmxform" id="commentForm" 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" onclick="$('#commentForm').validate().showErrors({'name': 'I know that your firstname is Pete, Pete!'});"/>
</p>
<p><input class="submit" type="submit" value="Submit"/></p>
</fieldset>
</form>
</body>
</html>
精彩评论