日期:2014-05-16 浏览次数:20434 次
<script type="text/javascript" src="js/jquery.js">
</script>
<script type="text/javascript" src="js/jquery.validate.min.js">
</script>
<script type="text/javascript" src="js/jquery.validate.message_zh.js">
</script>
<script type="text/javascript">
jQuery.validator.setDefaults( {
debug : true
});
</script>
<script type="text/javascript">
$().ready(function() {
$('#f1').validate( {
rules : {
loginname : {
required : true,
minlength : 6
},
password : {
required : true,
minlength : 6
}
},
messages : {
},
errorPlacement : function(error, element) {
error.appendTo(element.parent().next());
}
});
});
</script>
<style type="text/css">
label.error,label.error {
color: red;
}
</style>
</head>
<body>
<form class="cmxform" action="#" id="f1">
<table>
<tr>
<td>
username:
</td>
<td>
<input name="loginname" id="nickname" />
</td>
<td>
</td>
</tr>
<tr>
<td>
password:
</td>
<td>
<input name="password" id="password">
</td>
<td>
</td>
</tr>
<tr>
<td>
<input type="submit">
</td>
</tr>
</table>
</form>
<br />
</body>
</html>
('#f1').validate({
onfocusout:true,
.....
});