Menu icon Foundation
Clear search field after submit

Hi! I'm using a search field w/ submit button. When user hits 'submit' it triggers a random audio file. Nothing actually gets submitted or searched.

My problem is that the text remains in the field and I would like it to reset when 'submit' button is clicked.

What's the best way to go about this, being that I'm not technically performing a search?

(Using Rails 4)

Thanks!

rubyrailshtmljavascript

Hi! I'm using a search field w/ submit button. When user hits 'submit' it triggers a random audio file. Nothing actually gets submitted or searched.

My problem is that the text remains in the field and I would like it to reset when 'submit' button is clicked.

What's the best way to go about this, being that I'm not technically performing a search?

(Using Rails 4)

Thanks!

Ekku Jokinen about 4 years ago

Did you try googling your issue (on submit clear form fields)? You get lots of results and I think the first would be good (using javascript) http://stackoverflow.com/questions/15343890/clear-input-fields-on-form-submit

I'm not familiar with Rails 4 so I have no idea if it plays nicely with javascript but there you go.