修改了重复密码验证的js,精简代码量,减少了重复的校验,减少了valuedator中confirm的参数 [ci skip]
This commit is contained in:
@@ -22,13 +22,11 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.confirm = {
|
||||
|
||||
validate: function(validator, $field, options) {
|
||||
if (options.firstPassword.val() == options.secondPassword.val() ||options.secondPassword.val()== '')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (options.original.val() == $field.val() || $field.val()== '')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* usernameCheck validator
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
@@ -13,7 +12,6 @@
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation, csrfHeader) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
@@ -22,23 +20,18 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.usernameCheck = {
|
||||
|
||||
validate: function(validator, $field, options) {
|
||||
if ($field.val() == '')
|
||||
return true;
|
||||
return !$.ajax({
|
||||
async: false,
|
||||
beforeSend: csrfHeader,
|
||||
url: "/api/username_check/",
|
||||
data: {username: $field.val()},
|
||||
dataType: "json",
|
||||
method: "post",
|
||||
|
||||
|
||||
}).responseJSON.data;
|
||||
|
||||
async: false,
|
||||
beforeSend: csrfHeader,
|
||||
url: "/api/username_check/",
|
||||
data: {username: $field.val()},
|
||||
dataType: "json",
|
||||
method: "post",
|
||||
}).responseJSON.data;
|
||||
}
|
||||
};
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user