register js validation
This commit is contained in:
parent
4b912b9ae6
commit
9cd14f97c2
5 changed files with 55 additions and 15 deletions
|
@ -1,7 +1,9 @@
|
|||
var Gogits = {};
|
||||
var Gogits = {
|
||||
"PageIsSignup": false
|
||||
};
|
||||
|
||||
(function($){
|
||||
Gogits.showTooltips = function(){
|
||||
(function ($) {
|
||||
Gogits.showTooltips = function () {
|
||||
$("body").tooltip({
|
||||
selector: "[data-toggle=tooltip]"
|
||||
//container: "body"
|
||||
|
@ -13,10 +15,48 @@ var Gogits = {};
|
|||
}
|
||||
$(selector).tab("show");
|
||||
$(selector).find("li:eq(" + index + ") a").tab("show");
|
||||
}
|
||||
};
|
||||
Gogits.validateForm = function (selector, options) {
|
||||
var $form = $(selector);
|
||||
options = options || {};
|
||||
options.showErrors = function (map, list) {
|
||||
var $error = $form.find('.form-error').addClass('hidden');
|
||||
$('.has-error').removeClass("has-error");
|
||||
$error.text(list[0].message).show().removeClass("hidden");
|
||||
$(list[0].element).parents(".form-group").addClass("has-error");
|
||||
};
|
||||
$form.validate(options);
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
|
||||
function initCore(){
|
||||
function initCore() {
|
||||
Gogits.showTooltips();
|
||||
}
|
||||
|
||||
function initRegister() {
|
||||
$.getScript("/js/jquery.validate.min.js", function () {
|
||||
Gogits.validateForm("#gogs-login-card", {
|
||||
rules: {
|
||||
"username": {
|
||||
required: true,
|
||||
minlength: 5,
|
||||
maxlength: 30
|
||||
},
|
||||
"email": {
|
||||
required: true,
|
||||
email: true
|
||||
},
|
||||
"passwd": {
|
||||
required: true,
|
||||
minlength: 6,
|
||||
maxlength: 30
|
||||
},
|
||||
"re-passwd": {
|
||||
required: true,
|
||||
equalTo: "input[name=passwd]"
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue