About

Labels

slider

Recent

Navigation

Use jQuery submit() function in form without submitting it


While creating a popup menu with a search bar in it for my new design, I came across a new problem but later solved it. To make a input field to work on hitting enter, it is necessary to put in a form tag because this is what we call submitting a form.

But when I attached that form with submit() function the form submitted to no where. To tackle this we can have a simple solutions.
From a several uses of return false, this can be used in telling the function not to submit the form. Its easy to make, first create a form like:

HTML

<form class='searchform'>
   <input type='search' class='searchbar'>
</form>

jQuery

 $('.searchfrom').submit(function(){
 
// Do some magic here!
return false; // this is what stops form to submit
});
Share
Banner

Muhammad Hamza

Themelet provides the best in market today. We work hard to make the clean, modern and SEO friendly blogger templates.

Post A Comment:

0 comments: