Commit 091ecdca authored by Дмитрий Никулин's avatar Дмитрий Никулин Committed by Vitaly Lipatov

Add manual checking method

parent 3ade3c1f
......@@ -23,7 +23,7 @@
FIELD_SUCCESS = 'bg-true',
FIELD_INVALID = 'bg-false';
var EMAIL_REGEX = /^([^@\s]+)@(([a-zA-Z0-9\_\-]+\.)+([a-zA-Z]{2}|aero|arpa|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|post|pro|tel|travel|xxx))$/;
var EMAIL_REGEX = /^([^@\s]+)@(([a-zA-Z0-9\_\-]+\.)+([a-zA-Z]{2}|aero|arpa|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|post|pro|tel|travel|xxx|events))$/;
// TODO: избавиться от глобального состояния, лучше для каждой
// формы иметь свой набор таких полей
......@@ -189,12 +189,13 @@
emailNotice = $(notice);
$('body').prepend(emailNotice);
$('#notice_close_btn').click(closeNotice);
}
$('#notice_text').html(message);
emailNotice.removeClass().addClass(type);
$('#notice_close_btn').removeClass().addClass(type).click(closeNotice);
$('#notice_close_btn').removeClass().addClass(type);
lastNoticeType = type;
lastNoticeMessage = message;
......@@ -230,6 +231,7 @@
modifyField = !emailInput.hasClass('svcCheckEmail-nostyle');
var emailNotice, emailForm = emailInput.closest('form');
if (!emailForm.hasClass('manual')) {
emailForm.submit(function() {
var email = getEMail();
if (email === '') {
......@@ -255,6 +257,31 @@
return true;
});
}
window.checkEmail = function(callback) {
var email = getEMail();
if (email === '') {
setStatus(STATUS_ERROR, getErrorMessage(ERROR_EMPTY));
callback(false);
return;
}
if (status === STATUS_NONE) {
checkEmailFull(email, function (result) {
callback(result);
});
return;
}
if (status !== STATUS_SUCCESS) {
showSameNotice();
callback(false);
return;
}
callback(true);
};
emailInput.blur(function () {
var email = getEMail();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment