// Validation for the digital-asset-management.php form
<!--

function checkWholeForm()
{

  	var why 
	why = "";
	why += checkFname(document.formjoin.first_name.value)
	why += checkLname(document.formjoin.last_name.value)
  	why += checkEmail(document.formjoin.email.value)
	why += checkPHONE(document.formjoin.phone.value)
		
    if (why != "") 
		{
       alert(why)
       return false
    	}
return true
}



function checkEmail (strng) 
{
var erremail="";
var emailFilter=/^.+@.+\..{2,3}$/
var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
var at="@"
var dot="."
var lat=strng.indexOf(at)
var lstr=strng.length
var ldot=strng.indexOf(dot)


		if (strng == "") {
			erremail = "Please enter a valid email address.\n";
			return erremail
		}
		
		if (strng.indexOf(at)==-1){
		   erremail = "Your email address is not valid.\n";
		  
		   return erremail
		   
		}

		if (strng.indexOf(at)==-1 || strng.indexOf(at)==0 || strng.indexOf(at)==lstr){
		   erremail = "Your email address is not valid.\n";
		  
		   return erremail
		}

	

		 if (strng.indexOf(at,(lat+1))!=-1){
		   erremail = "Your email address is not valid.\n";
		  
		   return erremail
		 }

		 if (strng.substring(lat-1,lat)==dot || strng.substring(lat+1,lat+2)==dot){
		   erremail = "Your email address is not valid.\n";
		 
		   return erremail
		 }

	
		
		 if (strng.indexOf(" ")!=-1){
		   erremail = "Your email address is not valid.\n";
	
		   return erremail
		 }

		if (!(emailFilter.test(strng))) 
		{ 
       	erremail = "Your email address is not valid.\n";

		}

		if (strng.match(illegalChars)) 
		{
   		erremail = "Your email address contains illegal characters.\n";


		}
		
return erremail
}


function checkPHONE (strng) 
{


 	var errphone="";
	
  if (strng == "")
  {
	errphone="Please enter a correct phone number.\n";
  return errphone
  }
	
	
 	var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
	//strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped))) {
   		errphone = "Your phone number contains illegal characters."
		}
 
	if (!(stripped.length == 10)) {
		errphone = "Your phone number is the wrong length. Make sure you included an area code.\n"
		} 
 
return errphone 
}

function checkFname (strng) 
{
 var errname="";
	if ((strng.length < 2) || (strng.length > 14)) 
		{
    	errname = "The name must be between 2 - 14 characters.\n"
		}


	var illegalChars = /\W/
  	// allow only letters, numbers, and underscores
		if (illegalChars.test(strng)) 
		{
       	errname= "The name contains illegal characters.\n"
    	} 

return errname
 }
 
 
 
function checkLname (strng) 
{
 var errlname="";
	if ((strng.length < 2) || (strng.length > 14)) 
		{
    	errlname = "The last name must be between 2 - 14 characters.\n"
		}


	var illegalChars = /\W/
  	// allow only letters, numbers, and underscores
		if (illegalChars.test(strng)) 
		{
       	errlname= "The last name contains illegal characters.\n"
    	} 

return errlname
 }


//-->

