Skip to content

Instantly share code, notes, and snippets.

@truth4oll
Created March 26, 2015 22:51
Show Gist options
  • Select an option

  • Save truth4oll/7f00e13e8af6e19fece9 to your computer and use it in GitHub Desktop.

Select an option

Save truth4oll/7f00e13e8af6e19fece9 to your computer and use it in GitHub Desktop.
function form_init(form) {
form.find('input,textarea').on('focus',function(){
$(this).removeClass('error')
//$(this).next().fadeOut(100)
})
form.find('select').on('click',function(){
$(this).removeClass('error')
//$(this).next().fadeOut(100)
})
form.find('input').each(function(index,item){
var
item = $(item),
error_block = $('<div/>').addClass('error_text').append('<span class="arrow"></span><span class="text"></span>')
if (!item.hasClass('optional')) {
/* Проверка на заполненность - текстовые поля */
if (item.attr('type')=='text') {
//item.after(error_block)
}
}
})
form.on('beforeSubmit', function () {
$.ajax({
type: 'POST',
url: form.attr('action'),
data: form.serialize(),
success: function(msg) {
if (msg != 'ok') return false
setTimeout(function(){
if (form.attr('id') == 'form2') {
var html = '<span style="font-size:28px;font-weight:400">Ваша заявка отправлена.</span> <br /><br /> \
В скором времени с вами свяжется наш менеджер.</b>'
} else {
var html = '<span style="font-size:28px;font-weight:400">Ваша заявка отправлена.</span> <br /><br /> \
В скором времени с вами свяжется наш менеджер. <br /><br /> <b>Удачного дня!</b>'
}
form.html(html).css({
'font-size' : '20px',
'line-height' : '24px',
'text-align' : 'center'
})
return false;
},300)
}
})
return false;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment