Formvalidering?
Jeg har fundet dette script her på eksperten:************* SNIP ****************
function checkForm(frmName) {
for (i = 0; i < document.frmName.elements.length; i++) {
var which = document.frmName.elements[i];
var alertMsg = \"You must fill out all the mandatory fields\";
if (which.type == \"text\") {
if (which.value == \"\") {
alert(alertMsg);
which.focus();
return false;
}
} else if (which.type == \"textarea\") {
if (which.value == \"\") {
alert(alertMsg);
which.focus();
return false;
}
} else if (which.type == \"select-one\") {
if (which.options.selectedIndex == -1) {
alert(alertMsg);
which.focus();
return false;
}
} else if (which.type == \"select-multiple\") {
if (which.options.selectedIndex == -1) {
alert(alertMsg);
which.focus();
return false;
}
}
}
return true;
}
****************** SNIP ********************
Min Form-tag er som følger:
<form name=\"frmLitteraturStep1\" method=\"post\" action=\"litteratur.asp?action=step1\" onSubmit=\"return checkForm(this);\">
Dette giver mig fejlen:
\"document.frmName is null or not an object\"
(tror jeg nok det hedder)
Den bruger altså ikke variablen/argumentet...why?
(Scriptet ligger i en fil som includes (include file=\"xx\") i alle filer med forms.
/Dan
