Can i make it validate a username and password? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can i make it validate a username and password?

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

16th Aug 2017, 11:59 AM
Trapido02
Trapido02 - avatar
7 Answers
+ 8
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>
16th Aug 2017, 12:19 PM
Apoorva Shenoy Nayak
Apoorva Shenoy Nayak - avatar
+ 2
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.
16th Aug 2017, 12:08 PM
Calviղ
Calviղ - avatar
+ 1
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.
16th Aug 2017, 12:15 PM
Calviղ
Calviղ - avatar
0
can I use js?
16th Aug 2017, 12:10 PM
Trapido02
Trapido02 - avatar
0
or can I make it store the data in the script?
16th Aug 2017, 12:10 PM
Trapido02
Trapido02 - avatar
0
thats my contact form in js hope it helps :) https://code.sololearn.com/W73uL5j0oPBd/?ref=app
16th Aug 2017, 8:02 PM
Šimun Ivanac
Šimun Ivanac - avatar
0
thank you for the answers everybody. I found what I've been looking for! :D
16th Aug 2017, 8:25 PM
Trapido02
Trapido02 - avatar