Need to create a script for Gravity Forms to do 3 different functions on form submit: hide/show div, target=_blank, zip code check

Hello everyone,
I have a gravity form that has first, last name, email, zip code, and hidden is city and state. I need the form to perform the following 3 functions but can’t figure out how. My website is www yourpetinsurance com

  1. For the zip code, I am doing a zip code lookup which fills in the city and state (hidden) using a script from Ziptastic listed below which works great, but I need to activate GForms validation for the zip code field instead of a drop-down field that I added if they type in a fake zip code like 11111.

  2. On the main page I have 2 div’s with the id’s #body and #mediaAlpha which is hidden. On form submit, I need to hide the #body div and show the #mediaAlpha div.

  3. Finally, I need the form to submit to redirect to target=_blank

I looked at the add_filter( ‘gform_submit_button’ and gform_pre_render but couldn’t figure it out. Any help or feedback would be appreciated.

Thanks.

Below is the script from Ziptastic which does the zip code lookup and error checks if not valid.
script
function is_int(value) {
if ((parseFloat(value) == parseInt(value)) && !isNaN(value)) {
return true;
} else {
return false;
}
}
(function(){ //(".fancy-form div > div").hide();

("#input_3_3").keyup(function() { // Cache var el = (this);
// Did they type five integers?
if ((el.val().length == 5) && (is_int(el.val()))) {
// Call Ziptastic for information
.ajax({ url: "https://zip.getziptastic.com/v2/US/" + el.val(), cache: false, dataType: "json", type: "GET", success: function(result, success) { (".zip-error, .instructions").slideUp(200);
("#input_3_23").val(result.city); ("#input_3_24").val(result.state);
// (".fancy-form div > div").slideDown(); ("#input_3_3").blur();
("#address-line-1").show().focus(); }, error: function(result, success) { document.getElementById('input_3_22').value='Please enter a valid zip code'; (".zip-error").slideDown(300);
}
});
} else if (el.val().length < 5) {
$(".zip-error").slideUp(200);
};
});
})(jQuery);
/script

© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.