单击时提交表单 [英] Form submitting when clicked
问题描述
此登录系统有问题,每当我单击登录"按钮或注册"按钮时,它会将我重定向到写有白页的页面,也就是说,这正在干扰我的日志在行动.
I am having an issue with this login system, when ever I click the log in button, or the sign up button it re-directs me to a white page with writing on it, That being said it is interfering with my log in action.
这是我认为导致此问题的代码,
Here is the code that I think is causing the issue,
<form method="POST" action="" accept-charset="UTF-8">
在HTML代码的第16行,我尝试将代码取出,它停止了重新定向,但是文本框不正确,并且白色background/background-box也没有,
on line 16 of the HTML code, I tried to take that code out and it stopped the re-directing but the text boxes went out of place, and the white background/background-box was not there either,
链接, 此处
推荐答案
如果这纯粹是Java脚本,则要使用preventDefault():创建按钮时应该可以将按钮按下事件传递给侦听器: /p>
You want to use preventDefault() if this is a purely Javascript: you should be able to pass the button press event into the listener when you create it:
$('.login').on('click', function(e) {
e.preventDefault();
// Will be executed on press
}
<form method="POST" class="login" accept-charset="UTF-8">
如果在这种情况下不涉及JS,那么您想完全摆脱action参数-将其保留为空字符串在某些情况下仍会导致其重定向.
If there's no JS involved in this scenario, then you want to get rid of the action parameter entirely – leaving it as the empty string will still cause it to redirect in some cases.
这篇关于单击时提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!