You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

94 lines
3.2 KiB

$(function(){
$('input[name=city]').kladr({
type: $.kladr.type.city,
limit: 5
});
$('input[name=bday]').datepicker({
format: 'dd.mm.yyyy',
language: 'ru'
})
});
function sent_step(step){
// Отправка данных о этапе
var result = '';
var theForm = $(document.forms['step_'+step]).serialize();
$.ajax({
type: 'POST',
url: '/access/reg_step/',
data: theForm,
async: false,
success: function(data) {
if (data.code == '1'){
result = [true, data['data']]
} else {
result = [false, data['data']]
}
}
});
return result;
}
function check_step(step){
if ($('#checkBox').prop('checked') != true){
console.log('NOT PASS')
$('[name="error"]').html('Перед регистрацией ознакомтесь с договором-оферты');
$('#error_registration').fadeIn('fast');
} else {
// Проверка данных этапа - > Отправка данных
var result = sent_step(step);
if (result[0]){
if (step==3){
final_button()
}
close_step(step);
enable_step(step+1);
} else {
visible_error(step, result[1]['inputs'], result[1]['message'])
}
// Если все верно - > Переход на новый уровень
// Если нет - > Подсвечивание полей
//console.log('Получил запрос этапа '+step)
}
}
function enable_step(step){
// Активация этапа
$('li[step_number='+step+']').css('display', 'block');
$('div[role=progressbar]').css('width', step*33+'%');
}
function close_step(step){
// Скрытия этапа
// Скрытие li
$('li[step_number='+step+']').css('display', 'none')
}
function visible_error(step, inputs, message){
// Отображение ошибки
var li = $('li[step_number='+step+']');
var error_block = li.find('p[name=error]');
error_block.html(message);
var form = li.find('form[name=step_'+step+']');
var all_inputs = form.find('input');
for(var i=0;all_inputs.length>i;i++){
$(all_inputs[i]).css('border-color', '#cfdadd')
}
if (inputs) {
for (var i = 0; inputs.length > i; i++) {
error_input(form.find('input[name=' + inputs[i] + ']'))
}
}
}
function error_input(input){
// Подсвечивание поля
$(input).css('border-color', 'red')
}
function click_label(step){
if ($('label[step_number='+step+']').attr('class') == 'btn btn-primary activate'){
$('label[step_number='+step+']').attr('class', 'btn btn-primary activate')
} else {
$('label[step_number='+step+']').attr('class', 'btn btn-primary')
}
}
function final_button(){
$('[name=final_form]').append('<input type=text value="'+$('[name="email"]').val()+'" name="email" readonly style="display: none">' +
'<input type=text value="'+$('[name="password1"]').val()+'" name="password" readonly style="display: none">')
}