简体   繁体   English

使用Enter在同一页面上两次提交

[英]Use Enter to Submit twice on the same page

I'm adding a extra functionality to an existing program. 我在现有程序中添加了额外的功能。 Its a Login page to manage the time a user came in and out. 它的“登录”页面可管理用户进出的时间。 So first a login is asked, then (on the same page) a list with the login times are shown. 因此,首先要求登录,然后(在同一页面上)显示带有登录时间的列表。 The same button is used (just relabelled) for the login and time in/out. 登录和超时输入/退出使用相同的按钮(重新标记)。

The problem exist when users want to use enter to login and time in/out. 当用户要使用Enter进行登录和超时时,存在该问题。 So quickly press enter twice. 因此,请快速按两次Enter键。 No problems with the login. 登录没有问题。 But the second page wont recognize the enter. 但是第二页将无法识别回车。 even when I capture the keypress with JavaScript nothing happens. 即使使用JavaScript捕获按键,也不会发生任何事情。 I have to click the form (or a object in the form) so the enter would work. 我必须单击表单(或表单中的对象),这样输入才可以工作。

Tried UseSubmitBehavior, Javascript, changing focus. 尝试使用UseSubmitBehavior,Javascript,更改焦点。

I'm actually desperate and thinking of rewriting the whole thing. 我实际上很拼命,想重写整个事情。

Based in your description of this problem, I suggest two different options: 根据您对此问题的描述,我建议两个不同的选择:

  1. You can add both the login and the time in code under the same event. 您可以在同一事件下的代码中添加登录名和时间。 For example, when the user enters their login information and hits enter you can call the method to login the user and if successful then call the time-in method right after that - this should happen when the user hits enter, no need to do it twice. 例如,当用户输入他们的登录信息并按回车键时,您可以调用该方法来登录用户,如果成功,则在此之后立即调用time-in方法-这应该在用户按回车键时发生,无需这样做两次。
  2. Create another button. 创建另一个按钮。 One for the login and one for the time-in/out. 一种用于登录,一种用于超时。 After a user logs in, hide the login button and display the time-in/out button. 用户登录后,隐藏登录按钮并显示超时/退出按钮。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM