| Код | $(function() { // ... /*function show_notices (object, action) { if (action == 'show') { for (k in object) { if (k == 'birth') { $('#registration_' + k + '_notice').text(object[k]); $('#registration_' + k + '_notice_table_cell, #registration_' + k + '_notice').show(); } else if (k == 'recaptcha') { $('#registration_' + k + '_notice').text(object[k]).css('display', 'inline-block'); } else { $('#registration_' + k + '_notice').text(object[k]).show(); } } } else if (action == 'hide') { for (k in object) { if (k == 'birth') { $('#registration_' + k + '_notice').text(''); $('#registration_' + k + '_notice_table_cell, #registration_' + k + '_notice').hide(); } else { $('#registration_' + k + '_notice').text('').hide(); } } } }*/ var notices = {<? echo $notices_string; ?>}; show_notices (notices, 'show'); $('#registration_button').click(function() { show_notices (notices, 'hide'); notices = {}; /* Фамилия. if (!$('#registration_second_name').val().trim()) { notices.second_name = 'Заполните поле!'; } else { if ($('#registration_second_name').val().trim().length > 60 || /[^a-zA-Zа-яА-ЯёЁ\-]/.test($('#registration_second_name').val().trim())) { notices.second_name = 'Неверная фамилия!'; } }*/ // ... /* E-mail. */ if (!$('#registration_email').val().trim()) { notices.email = 'Заполните поле!'; } else { if ($('#registration_email').val().trim().length < 5 || $('#registration_email').val().trim().length > 60 || !/@/.test($('#registration_email').val().trim()) || !/\./.test($('#registration_email').val().trim()) || /[^\w-@.]/i.test($('#registration_email').val().trim())) { notices.email = 'Неверный e-mail!'; } else { $.ajax({ type: 'POST', url: '/pages/registration.php', data: 'm=check&email=lalka', complete: function() { notices.email = 'Пользователь с таким e-mail уже зарегистрирован!'; alert (notices.email); // 'Пользователь с таким e-mail уже зарегистрирован!' } }); alert (notices.email); // 'NaN' } } // ... if (object_is_empty(notices)) { $('form').submit(); } else { show_notices (notices, 'show'); var first_notice = '#registration_' + object_first_element(notices, 'k') + '_notice'; $('html, body').animate({ scrollTop: ($(first_notice).offset().top - $('.header').outerHeight() - 30) + 'px' }, 800, 'linear'); } }); });
|
|