Can i make it validate a username and password? | Sololearn: Learn to code for FREE!


Can i make it validate a username and password?

what can I do to make the script validate username and password without use databases?

8/16/2017 11:59:37 AM


7 Answers

New Answer


One way of looking at it- <form> <input type="text" placeholder="Username" id="text1" /><br /> <input type="password" placeholder="Password" id="text2" /><br /> <input type="button" value="Login" onclick="javascript:validate()" /> </form> <script type="text/javascript"> function validate() { if( document.getElementById("text1").value == "workshop" && document.getElementById("text2").value == "workshop" ) { alert( "validation succeeded" ); location.href="run.html"; } else { alert( "validation failed" ); location.href="fail.html"; } } </script>


Database is not a program, it can't validate data for us, it just for storing data. You use Javascript or PHP program to validate the form data.


Javascript can only store client local data using local storage or cookies. Means the stored data is only available for that local pc/phone only, each clients store their own individual data.


can I use js?


or can I make it store the data in the script?


thats my contact form in js hope it helps :)


thank you for the answers everybody. I found what I've been looking for! :D