Kligham
05-30-2009, 08:08 PM
Hey,
My form validation is almost ready, but there is still one thing with what I'm having troubles with. I need to check whether the people haven't filled in their username as there password.
So I need to check whether wachtwoord(password in english) = gebruikersnaam (username in english). And if so an error message should be shown. However it doesn't work.
Can anyone help me out with this probably 'easy' problem?
Here are the functions that I use to check my gebruikersnaam (username) and wachtwoord(password):
function checkField(el) {
if (el.id.toLowerCase() == 'gebruikersnaam') {
var gebruiker = el;
ray.getID(gebruiker.id+"_status").innerHTML = '' ;
if (gebruiker.value == null || gebruiker.value == '')
ray.showErrMsg('Gebruikersnaam: Het veld is leeg.',gebruiker.id+"_status");
else if (gebruiker.value.length < 2 )
ray.showErrMsg('Gebruikersnaam: Uw gebruikersnaam moet uit minimaal 2 tekens bestaan.',gebruiker.id+"_status");
else if (gebruiker.value.length > 16)
ray.showErrMsg('Gebruikersnaam: Uw gebruikersnaam mag niet meer dan 16 tekens bevatten.',gebruiker.id+"_status");
else if (!gebruiker.value.match(/^[a-z0-9\s]+$/i))
ray.showErrMsg('Gebruikersnaam: Enkel letters, cijfers en spaties zijn toelaten.',gebruiker.id+"_status");
else
ray.showCheck(gebruiker.id+'_status');
}
if (el.id.toLowerCase() == 'wachtwoord') {
var wachtwoord = el;
ray.getID(wachtwoord.id+"_status").innerHTML = '' ;
if (wachtwoord.value == null || wachtwoord.value == '')
ray.showErrMsg('Wachtwoord: Het veld is leeg.',wachtwoord.id+"_status");
else if (wachtwoord.value.length < 8 )
ray.showErrMsg('Wachtwoord: Uw wachtwoord moet uit minimaal 8 tekens bestaan.',wachtwoord.id+"_status");
else if (wachtwoord.value.length > 20)
ray.showErrMsg('Wachtwoord: Uw wachtwoord mag niet meer dan 20 tekens bevatten.',wachtwoord.id+"_status");
else if (!wachtwoord.value.match(/^[a-zA-Z0-9]+$/))
ray.showErrMsg('Wachtwoord: Enkel letters en cijfers zijn toegelaten.',wachtwoord.id+"_status");
This is where it goes wrong (the next two lines):
else if (wachtwoord.value == gebruiker.value)
ray.showErrMsg('Wachtwoord: Het opgegeven wachtwoord komt overeen met de gebruikersnaam, wat niet toegelaten is.',wachtwoord.id+"_status");
else
ray.showCheck(wachtwoord.id+'_status');
}
My form validation is almost ready, but there is still one thing with what I'm having troubles with. I need to check whether the people haven't filled in their username as there password.
So I need to check whether wachtwoord(password in english) = gebruikersnaam (username in english). And if so an error message should be shown. However it doesn't work.
Can anyone help me out with this probably 'easy' problem?
Here are the functions that I use to check my gebruikersnaam (username) and wachtwoord(password):
function checkField(el) {
if (el.id.toLowerCase() == 'gebruikersnaam') {
var gebruiker = el;
ray.getID(gebruiker.id+"_status").innerHTML = '' ;
if (gebruiker.value == null || gebruiker.value == '')
ray.showErrMsg('Gebruikersnaam: Het veld is leeg.',gebruiker.id+"_status");
else if (gebruiker.value.length < 2 )
ray.showErrMsg('Gebruikersnaam: Uw gebruikersnaam moet uit minimaal 2 tekens bestaan.',gebruiker.id+"_status");
else if (gebruiker.value.length > 16)
ray.showErrMsg('Gebruikersnaam: Uw gebruikersnaam mag niet meer dan 16 tekens bevatten.',gebruiker.id+"_status");
else if (!gebruiker.value.match(/^[a-z0-9\s]+$/i))
ray.showErrMsg('Gebruikersnaam: Enkel letters, cijfers en spaties zijn toelaten.',gebruiker.id+"_status");
else
ray.showCheck(gebruiker.id+'_status');
}
if (el.id.toLowerCase() == 'wachtwoord') {
var wachtwoord = el;
ray.getID(wachtwoord.id+"_status").innerHTML = '' ;
if (wachtwoord.value == null || wachtwoord.value == '')
ray.showErrMsg('Wachtwoord: Het veld is leeg.',wachtwoord.id+"_status");
else if (wachtwoord.value.length < 8 )
ray.showErrMsg('Wachtwoord: Uw wachtwoord moet uit minimaal 8 tekens bestaan.',wachtwoord.id+"_status");
else if (wachtwoord.value.length > 20)
ray.showErrMsg('Wachtwoord: Uw wachtwoord mag niet meer dan 20 tekens bevatten.',wachtwoord.id+"_status");
else if (!wachtwoord.value.match(/^[a-zA-Z0-9]+$/))
ray.showErrMsg('Wachtwoord: Enkel letters en cijfers zijn toegelaten.',wachtwoord.id+"_status");
This is where it goes wrong (the next two lines):
else if (wachtwoord.value == gebruiker.value)
ray.showErrMsg('Wachtwoord: Het opgegeven wachtwoord komt overeen met de gebruikersnaam, wat niet toegelaten is.',wachtwoord.id+"_status");
else
ray.showCheck(wachtwoord.id+'_status');
}