如何将重定向添加到HTML5表单?
我在我的网站上有2个表单,而不是提交这些表单,我希望用户在尝试提交表单时只需重定向到一个新的注册页面(让我们调用它) 代码如下——我将如何实现这一点 谢谢 FK如何将重定向添加到HTML5表单?,html,forms,Html,Forms,我在我的网站上有2个表单,而不是提交这些表单,我希望用户在尝试提交表单时只需重定向到一个新的注册页面(让我们调用它) 代码如下——我将如何实现这一点 谢谢 FK 表格一 <form action="" class="header-signup"> <input name="email" class="input-side" type="email" placeholder="Sign up now">
表格一
<form action="" class="header-signup">
<input name="email" class="input-side" type="email" placeholder="Sign up now">
<input type="submit" value="Go" class="btn-side">
</form>
表格二
<form action="" class="signup-form">
<input name="email" class="input-side animate-on-scroll" data-scrollanimation="fadeInLeft" type="email" placeholder="Your email address">
<input type="submit" value="Sign Up Now" class="btn-side animate-on-scroll" data-scrollanimation="fadeInRight">
</form>
试试:
函数moveToSignUpLocation(){
window.location=“[要注册的位置]”;
}
document.getElementById('txt-email')。onkeydown=function(e){
e=e | | window.event;
如果(如keyCode===13){
moveToSignUpLocation();
}
}
document.getElementById('btn-go')。onclick=function(){
moveToSignUpLocation();
};
为什么不直接设置为两个表单的action属性呢?谢谢……有一个小问题:它只在我单击“Go”按钮时起作用。如何在文本输入字段中按“回车”键启用重定向?
<form action="" class="header-signup">
<input name="email" id="txt-email" class="input-side" type="email" placeholder="Sign up now">
<input type="button" value="Go" id="btn-go" class="btn-side">
</form>
<script>
function moveToSignUpLocation() {
window.location = "[location to sign up]";
}
document.getElementById('txt-email').onkeydown = function(e) {
e = e || window.event;
if (e.keyCode === 13) {
moveToSignUpLocation();
}
}
document.getElementById('btn-go').onclick = function() {
moveToSignUpLocation();
};
</script>