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>

 

 ,这里面的id是t1,其他的类似

 function createValidation() {

jQuery(document).ready(function() { jQuery("#DB").validate( { event: "custom", rules: { tFieldRef: { required: true } }, messages: {tFieldRef: "*"} }); });

这是 老外写的一个例子

}

 

posted @ 2010-06-12 18:35  hevily  Views(276)  Comments(0Edit  收藏  举报