好吧,我想通过按Enter键但不显示提交按钮来提交表单.如果可能的话,我不想进入JavaScript,因为我希望所有浏览器都可以工作(我知道的唯一JS方式是事件).
现在表单看起来像这样:
<form name="loginBox" target="#here" method="post">
<input name="username" type="text" /><br />
<input name="password" type="password" />
<input type="submit" style="height: 0px; width: 0px; border: none; padding: 0px;" hidefocus="true" />
</form>
Run Code Online (Sandbox Code Playgroud)
哪个效果很好.当用户按下Enter键时,提交按钮会起作用,并且该按钮不会显示在Firefox,IE,Safari,Opera和Chrome中.但是,我仍然不喜欢这个解决方案,因为很难知道它是否适用于所有浏览器的所有平台.
有谁能建议更好的方法?或者这是否与它一样好?
<form method="POST" action="">
<input type="text" />
<input type="text" />
</form>
Run Code Online (Sandbox Code Playgroud)
(JSFiddle)
按回车键input.然后删除其中一个input并再次按下它.当我们在表单内部有两个输入时,表单未提交(我们需要一个按钮).这是为什么?