好的,我正在为一个网站制作表单,我遇到了一个问题。因此,当我试图验证html5的形式,它不能正常工作。我不知道我是否需要做些什么。我想这样当我提交按钮时它就会显示错误。但是它没有,它跳转到下一页。
我不知道该怎么办,有人能帮帮我吗?
这是表格。
<form>
<strong>
<p style="color:#63bbff">First Name:
</strong>
<input type="text" name="name" required ><br /></p>
<strong>
<p style="color:#63bbff">Minecraft Username(IGN):
</strong>
<input type="text" name="ign" required ><br /></p>
<strong>
<p style="color:#63bbff">Age:
</strong>
<input type="text" name="age" required ><br /></p>
<em>
<p style="color:#63bbff">When you understand the stated above, and ready to continue, click the button 'Continue'
<p>
</em>
<input type="submit" class="button" value="Continue" onclick="window.location='Index-3.html'" class="btn">
</form>
<button class="button" onclick="window.location='Index.html'">Previous</button>
你需要为表单写OnSubmit。
<form onsubmit="Index-3.html" >
并删除窗口。提交按钮的位置。点击这里查看你的演示
请将onclick="window.location='Index-3.html'"替换为onsubmit="window.location='Index-3.html'"
就像这样使用<form onsubmit="further()">
和submit字段:
<input type="submit" class="button" value="Continue" class="btn">
然后是js:
function further(){
window.location='Index-3.html';
}
演示:http://jsfiddle.net/swL9t/
或:
只需使用<form action="Index-3.html">
和提交按钮:
<input type="submit" class="button" value="Continue" class="btn">
演示:http://jsfiddle.net/swL9t/2/