Search code examples
ruby-on-rails-3form-submit

using buttons instead of input type="submit" in rails


I have a form that submits data.

Before I had used the submit_tag however, that converts to <input type="submit"

I wanted the buttons to look prettier so now I've started using <button> <span>login</span></button>

How can I submit the form using button the same way it was submitting with input type=submit ?


Solution

  • You could add a JavaScript event handler that obtains a reference to the form and submits it when the <button> element is clicked.