advertising landing popup form validation

remotes/origin/landing
ya_dim4ik 10 years ago
parent 8ef7b00241
commit 4168428b95
  1. 28
      static/advertising_landing/css/style.css
  2. 45
      static/advertising_landing/js/script.js

@ -844,32 +844,12 @@ input, .box {
font-family: 'Open Sans', sans-serif; font-family: 'Open Sans', sans-serif;
margin-bottom: 14px; margin-bottom: 14px;
} }
.popup-form__field.error{
/* border-color: #f00; */
box-shadow: 0px 0px 2px 2px #f00;
}
.popup-form__btn { .popup-form__btn {
margin-top: 15px; margin-top: 15px;
width: 350px; width: 350px;
} }
/*end popup*/ /*end popup*/

@ -44,25 +44,32 @@ $(document).ready(function(){
$("form.popup-form").on("submit", function(e){ $("form.popup-form").on("submit", function(e){
console.log('11'); console.log('11');
e.preventDefault(); e.preventDefault();
var $this = $(this), var $form = $(this),
url = $this.attr("action"), url = $form.attr("action"),
form = $this.serialize(); data = $form.serialize(),
$.post( type = $form.attr('method');
url,
form, $form.find('.error').removeClass('error');
function(data){
console.log(data); $.ajax({
if(data.success){ url: url,
// show thanks popup type: type,
$('.popup__close').click(); data: data,
$('.overlay').fadeIn(400, success: function(data){
function () { if (data.success) {
$('.popup-thank') $form.parents('.popup').fadeOut(200, function() {
.css('display', 'block') $('.popup-thank')
.animate({opacity: 1}, 200); .css('display', 'block')
}); .animate({opacity: 1}, 200);
});
} }
}
); if (data.errors) {
$.each(data.errors, function(i, val) {
$form.find('input[name="' + i + '"]').addClass('error')
});
}
}
});
}) })
}); });

Loading…
Cancel
Save