jquery 验证插件的简单入门使用
必须有form表单
给需要验证的文本框指定id,一会会用到的
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jquery.validate.js"></script>
<script type="text/javascript">
$(function(){
$("#form1").validate({
event:"keyup",
rules: {
t1:{
required:"true",
minlength:6
}
},
messages:{t1:"<font color=red>请输入大于6个字符</color>"}}
);
})
</script>
<script type="text/javascript" src="jquery.validate.js"></script>
<script type="text/javascript">
$(function(){
$("#form1").validate({
event:"keyup",
rules: {
t1:{
required:"true",
minlength:6
}
},
messages:{t1:"<font color=red>请输入大于6个字符</color>"}}
);
})
</script>
,这里面的id是t1,其他的类似
function createValidation() {
jQuery(document).ready(function() { jQuery("#DB").validate( { event: "custom", rules: { tFieldRef: { required: true } }, messages: {tFieldRef: "*"} }); });这是 老外写的一个例子
}