Prevent users from submitting a form by hitting Enter

后端 未结 30 3605
感动是毒
感动是毒 2020-11-21 05:13

I have a survey on a website, and there seems to be some issues with the users hitting enter (I don\'t know why) and accidentally submitting the survey (form) without clicki

30条回答
  •  闹比i
    闹比i (楼主)
    2020-11-21 05:35

    Instead of preventing users from pressing Enter, which may seem unnatural, you can leave the form as is and add some extra client-side validation: When the survey is not finished the result is not sent to the server and the user gets a nice message telling what needs to be finished to complete the form. If you are using jQuery, try the Validation plugin:

    http://docs.jquery.com/Plugins/Validation

    This will require more work than catching the Enter button, but surely it will provide a richer user experience.

提交回复
热议问题