I've just realised my password field isn't being validated.
And even if on the following page I query $password, and only pass thru if it's not NULL, it passes through.
<script>
function formCheck(formobj){
// Enter name of mandatory fields
var fieldRequired = Array("password");
// Enter field description to appear in the dialog box
var fieldDescription = Array("Password");
// dialog message
var alertMsg = "Sorry you have not given us all the information we need: please complete these fields too:\n";
var l_Msg = alertMsg.length;
for (var i = 0; i < fieldRequired.length; i++){
var obj = formobj.elements[fieldRequired[i]];
if (obj){
switch(obj.type){
case "select-one":
if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
case "select-multiple":
if (obj.selectedIndex == -1){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
case "text":
case "textarea":
if (obj.value == "" || obj.value == null){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
default:
}
if (obj.type == undefined){
var blnchecked = false;
for (var j = 0; j < obj.length; j++){
if (obj[j].checked){
blnchecked = true;
}
}
if (!blnchecked){
alertMsg += " - " + fieldDescription[i] + "\n";
}
}
}
}
if (alertMsg.length == l_Msg){
return true;
}else{
alert(alertMsg);
return false;
}
}
</script>
<form method='post' action='#' onSubmit="return formCheck(this)" name='check'>
password: <input type='password' name='password'>
<br/>
<input type='submit'>
</form>
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
You can't validate passwords in javascript because they are usually handled server side. It wouldn't make much sense to be able to manipulate passwords on the client side. Also, since usernames & passwords are usually checked and confirmed on the first page of a site (or before a user wants to do something that involves more than getting a page), why are you worried about checking it? It should have been checked before the above script comes up