HTML论坛不会提交

时间:2019-04-25 18:07:28

标签: javascript html

我正在尝试创建一个HTML论坛,该论坛在提交时执行一些javascript代码,但是在我提交该论坛时,它什么也没做。

我已经在Google上搜索以解决此问题,但找不到任何用处。

<forum class="forum" name="registration" onsubmit="return console.log('2');">
   <input class="forum-field" type="text" placeholder="Username" name="username" required/><br>
   <input class="forum-field" type="email" placeholder="Email" name="email" required/><br>
   <input class="forum-field" type="text" placeholder="Voornaam" name="firstname" required/><br>
   <input class="forum-field" type="text" placeholder="  Achternaam" name="lastname" required/><br>
   <input type="checkbox" required />
   <label>Ik ga akkoord met de Algemene Voorwaarden en Privacyverklaring. 
   </label><br>
   <input class="forum-submit" type="submit" value="Registreren"/>
</forum>

1 个答案:

答案 0 :(得分:1)

HTML中没有forum标签。 使用<form>

<form class="forum" name="registration" onsubmit="return console.log('2');">
   <input class="forum-field" type="text" placeholder="Username" name="username" required/><br>
   <input class="forum-field" type="email" placeholder="Email" name="email" required/><br>
   <input class="forum-field" type="text" placeholder="Voornaam" name="firstname" required/><br>
   <input class="forum-field" type="text" placeholder="  Achternaam" name="lastname" required/><br>
   <input type="checkbox" required />
   <label>Ik ga akkoord met de Algemene Voorwaarden en Privacyverklaring. 
   </label><br>
   <input class="forum-submit" type="submit" value="Registreren"/>
</form>