﻿    function validate()
        {

           if (document.getElementById('txtTitle').value=="")
	        {
		        alert("Please enter a Title");
		        document.getElementById('txtTitle').focus();
		        return false;
	        }
	        if(!IsTextValid(document.getElementById('txtTitle').value,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "))
	        {
	            alert("Title should be alpha numeric only.");
		        document.getElementById('txtTitle').focus();
		        return false;
	        }

	        if (document.getElementById('txtLink').value=="")
	        {
		        alert("Please enter link to your video");
		        document.getElementById('txtLink').focus();
		        return false;
        		
	        }
	         if (document.getElementById('txtName').value=="")
	        {
		        alert("Please enter Name");
		        document.getElementById('txtName').focus();
		        return false;
        		
	        }
	        if(!IsTextValid(document.getElementById('txtName').value,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz, "))
	        {
	            alert("Name should be alphabets only.");
		        document.getElementById('txtName').focus();
		        return false;
	        }
	        
	        if (document.getElementById('txtAge').value=="")
	        {
		        alert("Please enter Age");
		        document.getElementById('txtAge').focus();
		        return false;
        		
	        }
	        if(!IsTextValid(document.getElementById('txtAge').value,"0123456789, "))
	        {
	            alert("Age should be numeric only.");
		        document.getElementById('txtAge').focus();
		        return false;
	        }
	        
	         
        if(document.getElementById('ddlTeam').selectedIndex==0)
         {
            alert('Select which team you support');                       
            document.getElementById('ddlTeam').focus();
            return false;
         }
         if (document.getElementById('txtAddress').value=="")
	        {
		        alert("Please enter Address");
		        document.getElementById('txtAddress').focus();
		        return false;
        		
	        }
	        
	        if (document.getElementById('txtPhone').value=="")
	        {
		        alert("Please enter Phone");
		        document.getElementById('txtPhone').focus();
		        return false;
        		
	        }
	        if(!IsTextValid(document.getElementById('txtPhone').value,"0123456789-+(), "))
	        {
	            alert("Phone should not contain any special character.");
		        document.getElementById('txtPhone').focus();
		        return false;
	        }
	        if (document.getElementById('txtEmail').value=="")
	        {
		        alert("Please enter Email");
		        document.getElementById('txtEmail').focus();
		        return false;
        		
	        }
	        if(!checkemail(document.getElementById('txtEmail').value))
	        {
		        alert("Please enter valid Email Id.")
		        document.getElementById('txtEmail').focus();
		        return false;
	        }
	
	        if(document.getElementById('chkTerms').checked==false)
			{
			    alert("You must agree to the Terms & conditions.")
				document.getElementById('chkTerms').focus();
				return false;
			}

	        return true;
	    }
	    
	    
	    var testresults
function checkemail(str)
{
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
		testresults=true
	else
	{
		testresults=false
	}
	return (testresults)
}
	    
	    function IsTextValid(ctrlVal,validchars)
        {
            var blnresult=true;
            for(var i=0;i<ctrlVal.length && blnresult==true;i++)
            {
                var cchar=ctrlVal.charAt(i);
                if(validchars.indexOf(cchar)==-1)
                {
                    blnresult=false;
                }
            }
            return blnresult;
        }
        
        



