easyui远程ajax验证

一、有效方式

//扩展验证方法
$.extend($.fn.validatebox.defaults.rules, {
    checkSignCode:{//检查验证码
    	validator: function (value) {
    		var checkR=$.ajax({
                async : false,  
                cache : false,
                type : 'post',  
                url : '../signcode/check',  
                data : {  
                    'signcode' : value
                } 
            }).responseText;  
    		return checkR==="true"; 
        },
    	message: '验证码错误'
    }
    
}); 

二、无效方式

//扩展验证方法
$.extend($.fn.validatebox.defaults.rules, {
    checkSignCode:{//检查验证码
        validator: function (value) {
            var checkR=false;
            $.ajax({
                async : false,  
                type : 'post',  
                url : '../signcode/check',  
                data : {  
                    'signcode' : value
                },  
                success : function(result) {  
                    if (result === 'true') {  
                        checkR= true;  
                    }  
                }  
            });  
            return checkR; 
        },
        message: '验证码错误'
    }
}); 


你可能感兴趣的:(easyui)