html - JavaScript: How to redirect a page after validation -


i want redirect page after validation. have ff. example:

form.html:

<form method="post" action="" enctype="multipart/form-data" onsubmit="return checkform(this);"> <p><span style="width:180px">username: </span><input type="text" name="username" id='un'></p> <p><span style="width:180px">password: </span><input type="password" name="password" id='pw'></p> <input type="submit" value="submit" /> </form> 

script:

<script type='text/javascript'> function checkform(){     if(document.getelementbyid("un").value == 'jayem30' && document.getelementbyid("pw").value == 'jayem' ){         alert("login successful");         window.location = "http://www.google.com/"     }else{         alert("access denied. valid username , password required.");     } } </script> 

i tried not redirect google.com. many help! :)

try putting redirect in timeout. works charm

settimeout(function() {window.location = "http://www.google.com/" }); 

by way, instead of

onsubmit="return checkform(this);" 

use

onsubmit="return(checkform())" 

because ie doesn't when ommit ( , ).


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -