zoukankan      html  css  js  c++  java
  • bootstrap 表单validator与ajax验证!!!!

    话不多说,代码:

    $(document).ready(function() {  
           
            $('#defaultForm').bootstrapValidator({  
                message: 'This value is not valid',  
                feedbackIcons: {  
                    valid: 'glyphicon glyphicon-ok',  
                    invalid: 'glyphicon glyphicon-remove',  
                    validating: 'glyphicon glyphicon-refresh'  
                },  
                fields: {              
                    entry_code: {  
                        validators: {  
                            notEmpty: {  
                                message: '验证码不能为空'  
                            },  
                            stringLength: {  
                                min: 4,  
                                max: 4,  
                                message: '验证码长度为4位',  
                            },  
                              
                            remote: {  
                                url: CONTROLLER+'/ajax_check_code',  
                                message:"验证码不正确",  
                                type: "get",  
                                dataType: 'json',  
                                data: {  
                                      
                                },  
                                delay: 500,  
                            },  
                        }  
                    },  
                }  
            });  
        })  

    //下面为服务器怎么返回数据实例,看了很多网上都是说返回true、false,然而没软用!!!!!!!气死我了,写的不清不楚,还不如不写,坑人!!!最后找了半天才找到正确的返回格式!下面为代码:

    //如果用tp,其它的依葫芦画瓢,只要返回json数据就行!
    
            $code = I('entry_code');  
                if(check_verify($code)) {  
                    $this->ajaxReturn(array('valid'=>true,'message'=>'验证码正确'));  
                } else {  
                    $this->ajaxReturn(array('valid'=>false,'message'=>'验证码不正确'));  
                }  
  • 相关阅读:
    0827IO作业
    0927集合作业
    初学集合,以及泛型
    异常课——抛出
    Python环境变量配置
    安装Python
    MySQL多表操作
    MySQL增删改查
    Group by分组详解
    MySQL常用函数
  • 原文地址:https://www.cnblogs.com/lgqtecng/p/7040598.html
Copyright © 2011-2022 走看看