jillkatz
11-10-2007, 02:07 AM
1) Script Title: Required Field Validation
2) Script URL (on DD):
<script language="JavaScript">
<!--
/***********************************************
* Required field(s) validation v1.10- By NavSurf
* Visit Nav Surf at http://navsurf.com
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function formCheck(formobj){
// Enter name of mandatory fields
var fieldRequired = Array("name", "email", "employer", "address", "citystatezip", "phone");
// Enter field description to appear in the dialog box
var fieldDescription = Array("Name", "Email", "Employer", "Address", "City State Zip," "Phone");
// 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.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>
3) Describe problem: I am using this script however it doesn't validate the form first before going to the asp mail form
which is here: <form action="http://www.voicesforhousing.org/authorize.asp" method="post" name="FormMail" onsubmit="return formCheck(formobj);" id="FormMail">
How can I get the form to validate before it goes to the authorize.asp file or is there a way to put this information into the .asp file?
Thank you for your help.
2) Script URL (on DD):
<script language="JavaScript">
<!--
/***********************************************
* Required field(s) validation v1.10- By NavSurf
* Visit Nav Surf at http://navsurf.com
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function formCheck(formobj){
// Enter name of mandatory fields
var fieldRequired = Array("name", "email", "employer", "address", "citystatezip", "phone");
// Enter field description to appear in the dialog box
var fieldDescription = Array("Name", "Email", "Employer", "Address", "City State Zip," "Phone");
// 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.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>
3) Describe problem: I am using this script however it doesn't validate the form first before going to the asp mail form
which is here: <form action="http://www.voicesforhousing.org/authorize.asp" method="post" name="FormMail" onsubmit="return formCheck(formobj);" id="FormMail">
How can I get the form to validate before it goes to the authorize.asp file or is there a way to put this information into the .asp file?
Thank you for your help.