<script language="JavaScript">
<!--
function formCheck(formobj){
//1) Enter name of mandatory fields
var fieldRequired = Array("FirstName", "LastName");
//2) Enter field description to appear in the dialog box
var fieldDescription = Array("First Name", "Last Name");
//3) Enter dialog message
var alertMsg = "Please complete the following fields:\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.value == "" || obj.value == null){
alertMsg += " - " + fieldDescription[i] + "\n";
}
}
}
}
if (alertMsg.length == l_Msg){
return true;
}else{
alert(alertMsg);
return false;
}
}
//-->
</script>
<!--SAMPLE FORM -------------------------------->
<form name="formcheck" onsubmit="return formCheck(this);">
First Name: <input type=text name="FirstName" size="25"><br>
Last Name: <input type=text name="LastName" size="25"><br>
<input type=submit value="Submit Form">
</form>
dhtml, menu,
Nel nostro sito molte informazioni: "Morpheusweb.it - Risorse per Webmaster" tratta di dhtml, script, tendina, mail, forms click here se non sei reindirizzato automaticamente al
nostro sito.