# Clear text field with a button

**URL:** <https://discuss.rubyonrails.org/t/clear-text-field-with-a-button/58127>\
**Category:** rubyonrails-talk\
**Created:** [March 28, 2011, 1:04pm UTC](https://discuss.rubyonrails.org/t/clear-text-field-with-a-button/58127 "2011-03-28T13:04:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nahuel\_Garbezza](https://avatars.discourse-cdn.com/v4/letter/n/7c8e57/32.png) [@Nahuel\_Garbezza](https://discuss.rubyonrails.org/u/Nahuel_Garbezza)\
**Post date:** [March 28, 2011, 1:04pm UTC](https://discuss.rubyonrails.org/t/clear-text-field-with-a-button/58127/1 "2011-03-28T13:04:08Z")

</div>

Hi all,

I want to clear a text field by pressing a button, I get it work using Javascript but I want to know if there's a Rails way to do it.

Thanks, Nahuel.

---

<div class="post-metadata">

**Author:** ![Tim\_Shaffer2](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@Tim\_Shaffer2](https://discuss.rubyonrails.org/u/Tim_Shaffer2)\
**Post date:** [March 28, 2011, 2:30pm UTC](https://discuss.rubyonrails.org/t/clear-text-field-with-a-button/58127/2 "2011-03-28T14:30:55Z")

</div>

There isn’t a Rails way to do it. That’s a job for JavaScript, as you have already found.
