﻿function ValidateData()
{

     var elm=document.aspnetForm.elements;
            for(i = 0; i<elm.length; i++)
			   {
			     if(elm[i].type=="text" && elm[i].getAttribute("lname"))
		          {
		            if(elm[i].value=="")
		             {
		               alert(elm[i].getAttribute("lname")+" can not be blank.");
		               elm[i].style.background="yellow";
		               elm[i].focus();
		               return false;
		             }
		          }
	           } 
	            if(document.aspnetForm.ctl00_contPage_ddlContactChoice.value=="0")
	           {
	                alert("Please select contacted choice.");
		            document.aspnetForm.ctl00_contPage_ddlContactChoice.style.background="yellow";
		            document.aspnetForm.ctl00_contPage_ddlContactChoice.focus();
		            return false;
		        } 
		        
		         if(document.aspnetForm.ctl00_contPage_ddlCategory.value=="0")
	           {
	                alert("Please select category.");
		            document.aspnetForm.ctl00_contPage_ddlCategory.style.background="yellow";
		            document.aspnetForm.ctl00_contPage_ddlCategory.focus();
		            return false;
		        } 
		        
		        if(document.aspnetForm.ctl00_contPage_txtProductName.value=="0")
	           {
	                alert("Please enter product name.");
		            document.aspnetForm.ctl00_contPage_txtProductName.style.background="yellow";
		            document.aspnetForm.ctl00_contPage_txtProductName.focus();
		            return false;
		        }
		        
		        if(document.aspnetForm.ctl00_contPage_ddlQuantity.value=="0")
	           {
	                alert("Please select quantity.");
		            document.aspnetForm.ctl00_contPage_ddlQuantity.style.background="yellow";
		            document.aspnetForm.ctl00_contPage_ddlQuantity.focus();
		            return false;
		        } 
		        
		       
		        
		        if(document.aspnetForm.ctl00_contPage_ddlDate.value=="0")
	           {
	                alert("Please select date.");
		            document.aspnetForm.ctl00_contPage_ddlDate.style.background="yellow";
		            document.aspnetForm.ctl00_contPage_ddlDate.focus();
		            return false;
		        } 
		             
	           if(isNaN(document.aspnetForm.ctl00_contPage_txtTelephone.value))
	           {
	                alert("Telephone Number should be numeric.");
		            document.aspnetForm.ctl00_contPage_txtTelephone.style.background="yellow";
		            document.aspnetForm.ctl00_contPage_txtTelephone.focus();
		            return false;
		        } 
		       var RegExpression=/^(\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\s*[,;]?\b)*$/;
		      if(! RegExpression.test(document.aspnetForm.ctl00_contPage_txtEmail.value))
		      {
		        alert("Please fill valid Email address.");
		        document.aspnetForm.ctl00_contPage_txtEmail.style.background="yellow";
		        document.aspnetForm.ctl00_contPage_txtEmail.focus();
		        return false;
		       }     
		       
	             
}	    

//if((elm[i].type=="text" || elm[i].type=="textarea")   && elm[i].getAttribute("lname"))

