add_action( 'wp_footer', 'custom_footer_script', 99 ); function custom_footer_script() { ?> <script> jQuery(document).ready(function() { jQuery('.property-search-form').submit(function() { if (jQuery('#address_keyword').val() == '') { alert('Please enter a location'); return false; } return true; }); }); </script> <?php }