Help with Javascript Please
Silence 10 Feb 2008
Howdy!
I want to ask if there is a Possible JavaScript for this: I have a list of Family Names and First Names and in my 1st page I want 'those' people to enter their Family and First Names and after entering, it checks it if is listed on the list I mentioned.
Sorry for the Bad English hope everyone understands//
**ADDITIONAL**
And If the Names are invalid, a pop up beside the text area or something pops up saying that it is invalid or wrong...
THanks in Advance!
I want to ask if there is a Possible JavaScript for this: I have a list of Family Names and First Names and in my 1st page I want 'those' people to enter their Family and First Names and after entering, it checks it if is listed on the list I mentioned.
Sorry for the Bad English hope everyone understands//
**ADDITIONAL**
And If the Names are invalid, a pop up beside the text area or something pops up saying that it is invalid or wrong...
THanks in Advance!
Felix Lockhart 10 Feb 2008
Can it be done with Javascript? Sure.
Are you using this for some sort of login/authentication system? If so, you should only do it with Javascript if you have no other way of doing it; and even then, don't rely on it to actually secure anything. Since Javascript is client-side, anyone can view the source code and see what's needed to get in.
But, if this is just a comparison thing or a list-checker, it's fairly simple. Either way, it'd be helpful if you could give more info on what this will be used for :-)
Are you using this for some sort of login/authentication system? If so, you should only do it with Javascript if you have no other way of doing it; and even then, don't rely on it to actually secure anything. Since Javascript is client-side, anyone can view the source code and see what's needed to get in.
But, if this is just a comparison thing or a list-checker, it's fairly simple. Either way, it'd be helpful if you could give more info on what this will be used for :-)
Silence 10 Feb 2008
Its like a log-in, but doesnt need registration because its already listed on the "list" I mentioned. Get It? And cant we do the Javascript External, or it really needs to be Internal Code. And how about the Pop-Up thingy ever figured out how to do it?
Slightly Wonky Robob 10 Feb 2008
You can't 'hide' javascript from the client, you can only do that with server-side stuff.
what you are trying to do is fairly simple, there a few elements you need for this.
1. An array with all the names in, e.g.
Please note, i am by no means an expert in JS, so it might not be the 'best' way of doing it, but from what i can tell, what you are trying to would be better to be done server-side anyway
But either way, hope this helps
Edited by Bob, 10 February 2008 - 13:33.
what you are trying to do is fairly simple, there a few elements you need for this.
1. An array with all the names in, e.g.
<script type="text/javascript"> var names = new Array(); names[0] = new Array("Harry", "Potter"); names[1] = new Array("Bob", "IsAwesome"); function checkNames(firstname, surname){ for(i=0;i<names.length;i++){ if(firstname == names[i][0] && surname == names[i][1]){ return true; } } return false; } function buttonClick(){ var firstname = document.LogInForm.firstname.value; var surname = document.LogInForm.surname.value; if(checkNames(firstname, surname)){ alert("Logged in"); }else{ alert("not logged in"); } } </script> <form name="LogInForm"> <input type="text" name="firstname"> <input type="text" name="surname"> <input type="button" value="Check Names" onclick="buttonClick();"> </form>
Please note, i am by no means an expert in JS, so it might not be the 'best' way of doing it, but from what i can tell, what you are trying to would be better to be done server-side anyway
But either way, hope this helps
Edited by Bob, 10 February 2008 - 13:33.