フォームを使用して簡単なログインを行いたいのですが、ユーザーがパスワードを入力するための入力フィールドを持つフォームを作成し、ユーザーが送信ボタンを押す
パスワードはjavascripを使用して取得され、パスワードが正しい場合は新しいページが開きます
<script language="javascript">
function check(form)/*function to check userid & password*/
{
/*the following code checkes whether the entered userid and password are matching*/
if(form.password.value == "nopassword")
{
self.location='main.html'
}
else
{
alert("Wrong Password\nTry again Bak Choy Friend! :)")/*displays error message*/
}
}
</script>
.
.
.
<form>
<input type="text" placeholder="Password" name="password">
<input type="button" class="button" value="Login" onclick="check(this.form)"/>
</form>
しかし、問題は、ユーザーが新しいページを開く前に、1 回ではなく 2 回押す必要があることですか? 初めて、パスワードでボタンを押すと、アドレスバーが表示されます
...net/?password=nopassword
次に、パスワードでボタンを2回押すと、新しいページにリダイレクトされます。この問題を解決するにはどうすればよいですか?