Html5:表单验证“必需”不起作用

时间:2014-07-02 12:16:42

标签: html html5 forms

好的,我正在为一个网站的表单工作,我遇到了一个问题。因此,当我尝试在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>

3 个答案:

答案 0 :(得分:0)

好的,你需要为表单编写OnSubmit。

<form onsubmit="Index-3.html" >

并从提交按钮中删除Window.Location。查看您的演示here

答案 1 :(得分:0)

只需使用<form onsubmit="further()">和提交字段,如下所示:

<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/

答案 2 :(得分:0)

请替换onclick =&#34; window.location =&#39; Index-3.html&#39;&#34; onsubmit =&#34; window.location =&#39; Index-3.html&#39;&#34;