Two problems (Blocking and Missmatch).
Posted: Wed Jul 19, 2006 2:05 pm
I try to do 'Problematic characters blocking' and 'Characters length limitation' in all the forms in my site by call to one function.
The problems are:
1. The ''Problematic characters blocking' doesn't work well.
2. There's missmatch between the two fields (in this case). The password field works well and the username field doesn't.
I know I have some general problem in the way I defined the function, but I don't know what and how to fix the problem.
HTML code: (Please leave PHP codes)
JavaScript code:
*There's stylesheet for all. It's pointless to show the stylesheet because it's not the problem.
Thanks a lot,
Yoav.
The problems are:
1. The ''Problematic characters blocking' doesn't work well.
2. There's missmatch between the two fields (in this case). The password field works well and the username field doesn't.
I know I have some general problem in the way I defined the function, but I don't know what and how to fix the problem.
HTML code: (Please leave PHP codes)
Code: Select all
<div id="open_login" class="opens">
<form method="post" action="{$_SERVER['PHP_SELF']}">
<u><strong>LOGIN</strong></u><br />
<div style="width:10%;float:left;line-height:22px;">USERNAME:<br />PASSWORD:</div>
<div style="width:20%;float:left;">
<input type="text" name="username_login" id="username_login" onkeyup="javascript:check_login()" /><br />
<input type="password" name="password_login" id="password_login" onkeyup="javascript:check_login()" autocomplete="off" /><br />
<input type="submit" name="submit_login" id="submit_login" value=" LOGIN " disabled="disabled" style="height:25px;" />
</div>
<div id="username_login_errors" class="opens_errors">ERROR1</div>
<div id="password_login_errors" class="opens_errors">ERROR1</div>
</form>
</div>JavaScript code:
Code: Select all
function checks(c_value,c_errors,c_submit,c_dis) {
var checks_value = document.getElementById(c_value).value;
var checks_errors = document.getElementById(c_errors);
var checks_submit = document.getElementById(c_submit);
if((checks_value.length >= 3) && (checks_value.length <= 15)) {
checks_errors.style.color = "#008000";
checks_errors.innerHTML = "ALL FINE";
if((checks_value.match("%") == null) || (checks_value.match("'") == null) || (checks_value.match("\"") == null) || (checks_value.match("<") == null) || (checks_value.match(">") == null) || (checks_value.match("}") == null) || (checks_value.match("{") == null) || (checks_value.match(";") == null) || (checks_value.match("`") == null) || (checks_value.match("=") == null)) {
c_dis = 0;
}
else {
checks_errors.style.color = "#FF0000";
checks_errors.innerHTML = "ERROR2";
c_dis = 1;
}
}
else {
checks_errors.style.color = "#FF0000";
checks_errors.innerHTML = "ERROR1";
c_dis = 1;
}
if(c_dis == 0) {
checks_submit.disabled = false;
}
else {
checks_submit.disabled = true;
}
}
function check_login() {
checks('username_login','username_login_errors','submit_login',1);
checks('password_login','password_login_errors','submit_login',1);
}*There's stylesheet for all. It's pointless to show the stylesheet because it's not the problem.
Thanks a lot,
Yoav.