I want Enter Key not to submit a form. I did this first.
$("#send_c").keypress(function(e) {
if (e.which == 13) {
e.preventDefault();
return false;
}
});
But the button and Enter key work the same. Nothing happens or submitted even by the Enter key. My second try is this.
<%=form_for [@article, @article.comments.build], remote: true, :onsubmit=>"return false;" do |f| %>
<%=f.text_field :body, id: "c_i"%>
<%=f.button :submit, id: "send_c"%>
<%end%>
This did not work. The form is submitted both by Enter key and submit button.
What could be wrong?