Basic Form Validation
Function with validation for input type text, select, checkbox, and radio
<script language="JavaScript">
<!-- Hide the Javascript code

//set default message to nothing
function validateForm(){
var message=""; 

// Check for entry in a text field
if(document.FORMNAME.FIELDNAME.value.length==0){  
	message=message+"ENTER MESSAGE HERE.\n"; 
	}
	
// Check that something in a select box is chosen, other than first option. 
// Use "Please Select ..." or similar for first option

if(document.FORMNAME.SELECTNAME[document.FORMNAME.SELECTNAME.selectedIndex].value<1){
	message=message+"ENTER MESSAGE HERE.\n";
	}

//Check to see that a checkbox has been checked.
if (!(document.FORMNAME.CHECKBOXNAME.checked)) {
	message=message+"ENTER MESSAGE HERE.\n";
	}

//checks if a radio button has been checked
var rad_select = "no";
for (var loop = 0; loop < window.document.FORMNAME.RADIONAME.length; loop++)
	{
		if (window.document.FORMNAME.RADIONAME[loop].checked == true)
			{
				rad_select = "yes";
			}
	}
	if (rad_select=="no")
	{
		message=message+"ENTER MESSAGE HERE.\n";
	}

//checks to see if there is a message, if so, return message in alert box
if(message.length>0){ 
	message="You have left off some important information:\n"+message;
	alert(message);   
	return(false);
	}
else{
	return true;
	}
}//ends the function

//end hiding of code-->
</script>
 

cover
Buy Fusebox 5 & FLiP: Master-Class ColdFusion Applications
cover
Buy Fusebox 4 & FLiP: Master-Class ColdFusion Applications
cover
Buy ColdFusion Lists, Arrays, & Structures
cover
Buy ColdFusion XML Objects

Dedicated and Shared CF Hosting 2021