if statement - onsubmit: jQuery alert if field is empty -


on website, have button says "get free consultation" , next button email field. when user types in email , presses button, email submitted google spreadsheet, , popup appears more information.

how can add jquery code "onsubmit" part of tag says: if email field contains email address, submit form , show popup. otherwise ("else"), display alert box says "please enter email address."

here's code looks now:

<form action="https://docs.google.com/forms/d/xxxxx/formresponse" method="post" id="ss-form-landing" onsubmit="$('.landing-button').click();return true;" target="hidden_iframe">  <input type="text" name="entry.xxx" value="" id="entry_2005747986" class="landing-pg-email-field" placeholder="enter email address"><input type="submit" name="submit" value="get free &#x00a; consultation" class="landing-pg-button"> 

thanks in advance!

try

jquery(function($){     var $form = $('#ss-form-landing'), $field = $form.find('input.landing-pg-email-field');      $form.submit(function(){         if($.trim($field.val()) == ''){             alert('enter email id');             return false;         }     }) }) 

demo: fiddle


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -