LA_
LA_

Reputation: 20409

How to use search query form?

I have the following form:

<form class="navbar-search pull-left" action="http://www.example.com/movie/<id>" id="get-movie-form">
    <input type="text" class="search-query" placeholder="Input user id" id="get-movie">
</form> 

Once form is submitted/user pressed Enter, it should send GET request to http://www.example.com/movie/<id>, where <id> should be replaced with user input value.

Looks like the first what I should do is to prevent default form submission. I've tried the following code:

$("#get-movie-form").click(function(e) {
  e.preventDefault();
  return false;
});

but it doesn't work - the form is submitted anyway.

How to do what I've described above?

Upvotes: 1

Views: 123

Answers (1)

Zoltan Toth
Zoltan Toth

Reputation: 47667

Try

$("#get-movie-form").on("submit", function(e) {
    e.preventDefault();
    return false;
});

Upvotes: 2

Related Questions