html - Javascript will not redirect the form to the specified file path (or URL), with the dual option of pressing return key, or clicking submit button -
i beginner, , have researched week on roadblock. have tried many options make simple code work. the goal enter password, press enter or click submit button, redirect page specified url or file path. else have tried seems blank out function pressing enter won't work anymore, or next option redirect when password wrong, or next idea doesn't pop alert wrong password; examples:
tried using input type="button" onclick="2ndfunction" , having 2nd function trigger onsubmit() function..
tried using both input type="button" , input type="submit" separate form beneath input type="password" form. both, tried doing onclick or onsubmit functions check password.
form action="url.blah" redirect page url.blah if password wrong; password check, wronggg, redirect. form action="#" pretty obsolete or not necessary, , same thing well.
form method="post" or "get" doesnt function, besides send typed-in password somewhere unknown space/ server side/ current url.. unless implementing wrong..
there must simple fix, or simple missing here can add make come together. explaining in simple terms means understand well. understand security concerns, , security not concern function. appreciate help!!! here working (using notepad), in simple format:
<html> <body> <script type="text/javascript"> function onsubmit() {if (document.getelementbyid('password').value == '1234') {window.location.href = "https://www.google.com"; }else { alert('wronggg');} } </script> <form> <div> <label>enter passcode</label> <input type="password" name="password" id="password"/> </div> <input type="submit" value="enter" id="button" onclick="return (onsubmit())"/> </form> </body> </html>
it's lot simpler think. it's function in html
already.
<form method="post" action="yourfile.php">
make opening tag, , set file want go to. in case go file yourfile.php
on submit.
in file, can check if password
correct or not.
Comments
Post a Comment