1. Docs
  2. Developer Guide
  3. Miscellaneous and Snippets
  4. Make Location A Mandatory Field In Search Forms

Make Location A Mandatory Field In Search Forms

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
}
Was this article helpful to you? Yes No