ashsaraga
5/24/2018 - 10:01 PM

BSD Form Widget

For hosting BSD forms externally.

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script>
		$( document ).ready(function() {
			  $('#bsd-error, #bsdfielderror, #thank-you').hide();
			   $('form[name="signupform"]').submit( function(event){ process_form_submission(event); } );
		});
		function process_form_submission( event ) {
		event.preventDefault();
          alert('message');
	      var form = $('form');
		  $('.required').each(function(){
	       if ( $(this).val() == "" ){
	         $(this).addClass('alert');
	       }
	      });
	      form.find('.error').remove();
	      form.data('data', form.serialize());
	      if ( $('.alert').length > 0 ){
	        $('#bsd-error').show();
	        $("form input[type='submit']").val('Submit Form');
	      } else {
	        $.ajax({
	          url: 'https://stopcuomo.cp.bsd.net/page/sapi/landing-page-form',
	          type: 'POST',
	          dataType: 'json',
	          data: form.data('data'),
	          success: function() {
			$('form').hide();
	          	$('#thank-you').show();
	          },
	          error: function(data) {
			$('form').hide();
	          	$('#thank-you').show();
	          }
	        });
	      }
	      return false;
      }
    </script>
</head>

<body>

<form action="#" name="signupform">
	<div id="bsd-error">Please fill out all of the form fields.</div>
    <input class="required" type="email" size="48" id="email" name="email" placeholder="Email Address">
    <input class="required" size="8" id="zip" name="zip" type="text" placeholder="Zip Code">
    <input size="8" id="source" name="source" type="hidden">
    <input class="btn" name="submit-btn" value="I agree" type="submit">
</form>
<div id="thank-you">Every person who shares this petition helps us reach 3 more people. 
<ul class="social"><li><a href="https://www.facebook.com/sharer/sharer.php?u=http%3A//stopthecuomotax.org/"><span class="icon-facebook"></span></a></li> <li><a href="https://twitter.com/home?status=.%40NYGovCuomo%20wants%20to%20increase%20our%20electric%20bills%20to%20bailout%20old%20and%20unsafe%20nuclear%20power%20upstate.%20%23StopTheCuomoTax%0Ahttp%3A//stopthecuomotax.org/"><span class="icon-twitter"></span></a></li> </ul>
</div>

</body>
</html>