私はピンとpswdがフォームと一致することを確認するフォームを作成しようとしています。しかし、私は何が欠けているか分からない。私はWebDevの世界で少し若く、私は本当に単純な(私の頭の中で)すべき何かを見つけ出そうと愚かな時間を費やしました。私はこの5つの方法を試して、それを愚かにしています。私は本質的に誰かからコピーされたものであり、それは私のためには機能しません。任意のヒント?基本的に一致するかどうかをチェックするために2つの入力を取得する必要があります。 FYI:私が働いているファイルは、initialsetup3SANDBOX.phpと呼ばれています。パスワード一致の確認
function myFunction() {
var pass1 = document.getElementById("pass1").value;
var pass2 = document.getElementById("pass2").value;
if (pass1 != pass2) {
//alert("Passwords Do not match");
document.getElementById("pass1").style.borderColor = "#E34234";
document.getElementById("pass2").style.borderColor = "#E34234";
} else if {
alert("Passwords Match!!!");
document.getElementById("regForm").submit();
}
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form id="regform" action="/initialsetup3SANDBOX.php" method="post" onsubmit="return myFunction();">
<input id="pass1" type="password" placeholder="Password" style="border-radius:7px; border:2px solid #dadada;"><br>
<input id="pass2" type="password" placeholder="Confirm Password" style="border-radius:7px; border:2px solid #dadada;"><br>
</form>
<input type="submit" value="Submit">
</body>
</html>
あなたが取得している結果とは何ですか? – Vedant
'else if {'が正しい構文でない場合、 'else if(* condition *){'または 'else {' – George
はありません。エラーは発生しません。私はちょうどsubmitをクリックし、何も起こらない。 –