Make sure to include all the necessary scripts: jquery.js
, jquery.validate.js
and jquery.metadata.js
(if you are using class metadata to define validation rules)? Here's a sample:
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.min.js"></script>
<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/lib/jquery.metadata.js"></script>
<script type="text/javascript">
$(function() {
$('#aspnetForm').validate();
$('a').click(function() {
alert($('#aspnetForm').validate().form());
return false;
});
});
</script>
</head>
<body>
<form id="aspnetForm" action="#">
<input name="other" type="radio" />
<input name="details" type="text" class="{required:true}" />
<input type="submit" value="OK" />
</form>
<a href="#">Validate</a>
</body>
</html>