我对此很陌生,无法弄清我的学校项目有什么问题。我认为也许我的javascript文件未正确链接,或者代码只是坏了?
// }
// Commented out above "}" - Edits must be at least 6 characters
function repost() {
var epost = document.getElementById('epost');
var repost = document.getElementById('repost');
if (epost.value != repost.value) {
repost.setCustomValidity('Epost adresserna måste matcha.');
} else {
// input is valid -- reset the error message
repost.setCustomValidity('');
}
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Skapa konto</title>
<link href="Stilmall.css" rel="stylesheet" type="text/css">
<script>var __adobewebfontsappname__="dreamweaver"</script>
<script src="http://use.edgefonts.net/abel:n4:default.js" type="text/javascript"></script>
<script src="reg.js" type="text/javascript"></script>
</head>
<body>
<div class="form1">
<form name="form2" id="form3" method="post" onsubmit="return validateForm();" action="tack.html">
<p class="form_text">
<input type="text" id="epost" placeholder="E-post" required>
<input type="text" id="repost" placeholder="Repetera E-post" required oninput="repost(this)">
</p>
<p class="form_text">
<input type="submit" id="sumbit" value="Registrera">
</p>
</form>
</div>
</body>
</html>
答案 0 :(得分:1)
嗯,这有点棘手,但是您的ID和函数名称都为“ repost”,在这种情况下,您会得到一个错误,提示(foo A/B or C)
,您必须更改函数或ID的名称。这已经在这里讨论:Why JS function name conflicts with element ID?
也不要忘记在if条件下修正错字。