我正在使用淘汰赛验证插件,但我没有得到如何验证验证是真还是假
ko.validation.rules['remote'] = {
async: true,
validator: function ( val, parms, callback ) {
var defaults = {
url: '/ajax/auth',
type: 'POST',
success: callback
};
var options = $.extend( defaults, parms );
$.ajax( options );
},
message: 'Default Invalid Message'
};
var username = ko.observable().extend({ remote : { data: {email : username} }});
// setting it will trigger validation
username.isValidating.subscribe(function(isValid){
if(isValid){
// save the username or whatever you do
}else{
// invalid
}
// ajax.php
function isValidEmail(){
$data = $this->input->get_post();
return is_valid_email($data['email']);
};
我总是变得无效请解释这是如何工作的