From 82cd80a8ff5a70b4741e57ede7f6dcf573b19573 Mon Sep 17 00:00:00 2001 From: Maxime Date: Thu, 9 Nov 2017 13:32:00 +0100 Subject: [PATCH] fix form validation (#236) --- docs/_includes/join-form.haml | 4 ++-- docs/js/home.js | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/_includes/join-form.haml b/docs/_includes/join-form.haml index c80dee8d..7a655ea5 100644 --- a/docs/_includes/join-form.haml +++ b/docs/_includes/join-form.haml @@ -1,4 +1,4 @@ -%form.join-form.gradient-white.pos-rel.z-10.p-xlarge.p-l-xxlarge.p-r-xxlarge.radius6.elevation1.m-l-r-auto{action: '#', method: 'POST'} +%form.join-form.join-form-fill.gradient-white.pos-rel.z-10.p-xlarge.p-l-xxlarge.p-r-xxlarge.radius6.elevation1.m-l-r-auto %header.text-center %h3.color-bunting.text-demi.no-margin.text-lg Get Started. It’s FREE! .spacer32 @@ -25,7 +25,7 @@ %button.btn.btn-static-primary.w100p{type: 'submit'} Join the program -%form.join-form.join-form-validated.hidden +%form.join-form.join-form-validated.gradient-white.pos-rel.z-10.p-xlarge.p-l-xxlarge.p-r-xxlarge.radius6.elevation1.m-l-r-auto.hidden %h3 Thank you ! .spacer20 %p.text-sm diff --git a/docs/js/home.js b/docs/js/home.js index d0e10b1c..7e891c9e 100644 --- a/docs/js/home.js +++ b/docs/js/home.js @@ -8,7 +8,8 @@ } $('.join-form').on('submit', function(e) { - var $button = $(this).find('button'); + e.preventDefault(); + var $email = $(this).find('input[name="email"]'); var $url = $(this).find('input[name="url"]'); var $owner = $(this).find('input[name="owner"]'); @@ -29,27 +30,26 @@ if (error) { return false; } - $button.attr('disabled', true); + $.ajax({ url: 'https://www.algolia.com/docsearch/join', type: 'POST', data: { email: $email.val(), - url: $url.val(), - }, - }) - .done(function() { + url: $url.val() + } + }).done(function() { pardotAppendIframe( 'https://go.pardot.com/l/139121/2016-08-05/ldp67?email=' + encodeURIComponent($email.val()) + '&website=' + encodeURIComponent($url.val()) ); - $('.join-form').hide(); - $('.join-form-validated').show(); + + $('.join-form-fill').hide(); + $('.join-form-validated').removeClass('hidden'); }) .fail(function() { - $button.attr('disabled', null); alert('An error occurred, please try again later.'); });