|
Hi - I know very little about javascript and I've been tasked with creating a form which validates the entries in 5 different password fields as well as other fields such as email etc.
The idea is that you have to enter 5 correct and different passwords into the form and only if all 5 are correct will you be forwarded to a thank you page.
If any of the passwords are wrong you will get an error message and the incorrect field(s) will be highlighted.
Any ideas as where to start on this?
|
|
|
Most javascript loging are not secure. 90% of the javascript logings i have seen are easy to pass.
to make it hard you will have to store the passwords in a location that only the javascript can read, which is kinda hard to do.
maybe using .htaccess file on the server to block web browsers the right to read it.
Or encode the passwords with an encryption and when the passwords typed are matched they are encrypted then matched with the good passwords that are encrypted also, for this way you should use a one way encryption like md5 or SHA so its harder to decode the encoded passes.
But if your looking for a secure login Perl, PHP, asp are langs to look into.
|
|
|
but if the location you want secure is viewable in the javascript a hacker could bypass the hole code and go straight to the hidden location.
|
|
|
Hi - security isn't such a big issue for this project - the 5 passwords thing is more of a gimic - as long as the passwords are in a seperate .js file then that's ok. Where I'm stuck is writing a function that firstly validates the user input against the specific password strings and writing it so that if any one of the 5 passwords is wrong the sumbit fails.
|
|
|
Ok well this is about what your looking for. I`m not sure in javascript if && meens and in the if statments i made but thats just a little bit of editing to change that...
var Value1
var Value2
var Value3
var Value4
var Value5
var Checked
function verify(Value1,Value2,Value3,Value4,Value5)
{
if (Value1 == "N")
{
Checked = 1;
} else { window.location.href="/forum/Error.htm"; }
if (Checked == 1 && Value2 == "W")
{
Checked = 2;
} else { window.location.href="/forum/Error.htm"; }
if (Checked == 2 && Value3 == "E")
{
Checked = 3;
} else { window.location.href="/forum/Error.htm"; }
if (Checked==3 && Value4 == "S")
{
Checked = 4;
} else { window.location.href="/forum/Error.htm"; }
if (Checked==4 && Value5 == "S")
{
Checked = "PASSED";
} else { window.location.href="/forum/Error.htm"; }
if (Checked=="PASSED")
{
window.location.href="/forum/PASSED.htm";
} else { window.location.href="/forum/Error.htm"; }
}
now to use the function
verify(document.form_name.value1.value,document.form_name.value2.value,document.form_name.value3.value,document.form_name.value4.value,document.form_name.value5.value);
valueX is the name of the form input value
This should work, Sorry i didnt test it..
Flex,
|
|
|
Excellent - thanks for your help, I'm off to play with the code :)
|
|
|