修改了重复密码验证的js,精简代码量,减少了重复的校验,减少了valuedator中confirm的参数 [ci skip]

This commit is contained in:
sxw
2015-08-04 19:54:44 +08:00
parent 1d4af5cc7c
commit 0b55f6bbf7
5 changed files with 14 additions and 64 deletions

View File

@@ -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;
}
};
}));