HTML Form button press twice to open new page

MechaLaser

New Member
I want to make a simple login using form, i create a form that has input field for user to key in password and then the user press submit buttonthe password will be retrieved using javascrip, if the password is correct it will open a new page \[code\]<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 =http://stackoverflow.com/questions/15716476/="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="http://stackoverflow.com/questions/15716476/Login" onclick="check(this.form)"/> </form>\[/code\]But the problem is it requires the user to press twice instead of one before it can open a new page? the first time, i press the button with the password, the address bar displays...net/?password=nopasswordthen, the 2nd time i press the button with the password, it will redirect me to the new pagemay i know how can i solve this problem?
 
Back
Top