dty63504
2013-07-25 11:10
浏览 65
已采纳

在textarea字段中按enter键刷新页面

I'm using Symfony2 but i'm experiencing a troubling thing.

I have a form, with a textarea field, but each time i press 'enter' to go to the next line it refresh the page (without deleting the previous line)..

Do you have any idea where does it come from?

Thanks!

图片转代码服务由CSDN问答提供 功能建议

我正在使用Symfony2,但我遇到了一件令人不安的事情。

我有一个带有textarea字段的表单,但每次按'enter'转到下一行它会刷新页面(不删除上一行)..

Do 你知道它来自哪里吗?

谢谢!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • donglan9517 2013-07-25 11:23
    已采纳

    Well for sure you have a submit button on the form. On enter in a form you call the submit butt that refreshes the page!

    In order to prevent that you can just make the button in the type="button" and bind a onclick function so that the submit button is not called on enter!

    However; you will remove the enter feature that calls the submit on the entire form not just in the text area!

    OR --> you can just call a function on keypres or keyup on the text area and e.prevetnDefault();

    I hope my answers helps you!

    点赞 打赏 评论

相关推荐 更多相似问题