$(function(){
$(document).ready(function() {
/* SEARCH FIELD */
$('#searchform').submit(function(e) { // submit function pin when event occur
var s = $( this ).find("#s");
if (s.val() == "") {
e.preventDefault(); // stop default submission
alert("ERROR! Search Field is Empty.");
$('#s').focus();
}
});
});
Use below code in function.php
function my_search_form( $form ) {
$form = '<fieldset><legend>Search:</legend>
<form id="searchform" class="searchform" action="' . home_url( '/' ) . '" method="get">
<div><label class="screen-reader-text" for="s">' . "" . '></label>
<input id="s" name="s" type="text" value="' . get_search_query() . '" placeholder="Please Text Your Search Item..." />
<input id="searchsubmit" type="submit" value="'. esc_attr__( 'Search...' ) .'" />
</div>
</form>
<fieldset>';
return $form;
}
add_filter( ‘get_search_form’, ‘my_search_form’ );
wp_register_script(‘ig_jquery’, esc_url(get_template_directory_uri()).’/js/ig_jquery.js’);
wp_enqueue_script(‘ig_jquery’);
}
Also, your search template file may be in search.php file and you can use below code.
Also, your search template file may be in search.php file and you can use below code.
/* Template Name: Search */ <div class="search_box"> <?php get_search_form(); ?> </div> <!-- end of search box -->


No comments:
Post a Comment