﻿function validate(frm)
    {
        var fields="";
     
		if (frm.last.value == ""){
            fields = "Family Name\n";
        }
 	   if (frm.first.value == ""){
            fields = fields + "First Name\n";
        }
 		      
	   if (frm.tel.value == ""){
            fields = fields + "Telephone\n";
        }
		
		
		if (frm.email.value == ""){
            fields = fields + "Email\n";
        }
	
	   
	   if (fields != "") {
	   alert('The following required fields are missing: \n\n' + fields );
	   return false;
	   }
		return true;
    }
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='Email must contain a valid e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) {
  alert(''+errors);
  formim.email.focus();
  }
  document.MM_returnValue = (errors == '');
}


function ValidateInput()
	{
		if (document.getElementById('<%=txtYourName.ClientID%>').value=="" || document.getElementById('<%=txtYourEMail.ClientID%>').value=="")
		{
			window.alert("Please specify at least one friend's name and email.");
			document.getElementById('<%=txtYourName.ClientID%>').focus();
			return false;
		}
		if (document.getElementById('<%=txtYourName1.ClientID%>').value !="" ^ document.getElementById('<%=txtYourEMail1.ClientID%>').value!="")
		{
		    window.alert("Please specify both name and email address for 1st friend.");
		    document.getElementById('<%=txtYourEMail1.ClientID%>').focus();
		    return false;
		}
		if (document.getElementById('<%=txtYourName2.ClientID%>').value!="" ^ document.getElementById('<%=txtYourEMail2.ClientID%>').value!="")
		{
	
			window.alert("Please specify both name and email address for 2nd friend.");
			document.getElementById('<%=txtYourName2.ClientID%>').focus();
			return false;
	
		}
		if (document.getElementById('<%=txtYourName3.ClientID%>').value!="" ^ document.getElementById('<%=txtYourEMail3.ClientID%>').value!="")
		{
			window.alert("Please specify both name and email address for 3rd friend.");
			document.getElementById('<%=txtYourName3.ClientID%>').focus();
			return false;
		}
		if (document.getElementById('<%=txtYourName4.ClientID%>').value!="" ^ document.getElementById('<%=txtYourEMail4.ClientID%>').value!="")
		{
			window.alert("Please specify both name and email address for 4th friend.");
			document.getElementById('<%=txtYourName4.ClientID%>').focus();
			return false;
		}
		if (document.getElementById('<%=txtYourName5.ClientID%>').value!="" ^ document.getElementById('<%=txtYourEMail5.ClientID%>').value!="")
		{
			window.alert("Please specify both name and email address for 5th friend.");
			document.getElementById('<%=txtYourName5.ClientID %>').focus();
			return false;
		}
		return true;
	}


function ValidateInput1()
	{
		
		if (frmRefer.txtYourName.value=="")
		{
			window.alert("Please specify your name.")
			frmRefer.txtYourName.focus()
			return false
		}
		if (frmRefer.txtYourEMail.value=="")
		{
			window.alert("Please specify your email address.")
			frmRefer.txtYourEMail.focus()
			return false
		}
		
		if (frmRefer.txtYourName1.value!="" || frmRefer.txtYourEMail1.value!="")
		{
			if (frmRefer.txtYourName1.value=="" || frmRefer.txtYourEMail1.value=="")
			{
				window.alert("Please specify both name and email address for 1st friend.")
				frmRefer.txtYourName1.focus()
				return false
			}
		}
		if (frmRefer.txtYourName2.value!="" || frmRefer.txtYourEMail2.value!="")
		{
			if (frmRefer.txtYourName2.value=="" || frmRefer.txtYourEMail2.value=="")
			{
				window.alert("Please specify both name and email address for 2nd friend.")
				frmRefer.txtYourName2.focus()
				return false
			}
		}
		if (frmRefer.txtYourName3.value!="" || frmRefer.txtYourEMail3.value!="")
		{
			if (frmRefer.txtYourName3.value=="" || frmRefer.txtYourEMail3.value=="")
			{
				window.alert("Please specify both name and email address for 3rd friend.")
				frmRefer.txtYourName3.focus()
				return false
			}
		}
		if (frmRefer.txtYourName4.value!="" || frmRefer.txtYourEMail4.value!="")
		{
			if (frmRefer.txtYourName4.value=="" || frmRefer.txtYourEMail4.value=="")
			{
				window.alert("Please specify both name and email address for 4th friend.")
				frmRefer.txtYourName4.focus()
				return false
			}
		}
		if (frmRefer.txtYourName5.value!="" || frmRefer.txtYourEMail5.value!="")
		{
			if (frmRefer.txtYourName5.value=="" || frmRefer.txtYourEMail5.value=="")
			{
				window.alert("Please specify both name and email address for 5th friend.")
				frmRefer.txtYourName5.focus()
				return false
			}
		}
		return true
	}
	
	
	
	
	 function ValidationEmail(ID)
    { 
        var Name= document.getElementById(ID).value;
        if (Name!="")
        {
            var emailPat = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
            var emailid=document.getElementById(ID).value;
            var matchArray = emailid.match(emailPat);
            if (matchArray == null)
            {
                alert("-Invalid Email.");
                document.getElementById(ID).value="";
                document.getElementById(ID).focus();
                return false;
            }
        }
     }