﻿function echeck_stdform(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   document.getElementById("diverrormsgmail").innerHTML ="Invalid email!"
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   document.getElementById("diverrormsgmail").innerHTML ="Invalid email!"
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    
		     document.getElementById("diverrormsgmail").innerHTML ="Invalid email!"
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    
		    document.getElementById("diverrormsgmail").innerHTML ="Invalid email!"
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   
		     document.getElementById("diverrormsgmail").innerHTML  ="Invalid email!"
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    
		     document.getElementById("diverrormsgmail").innerHTML  ="Invalid email!"
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    
		     document.getElementById("diverrormsgmail").innerHTML  ="Invalid email!"
		    return false
		 }

 		 return true					
	}

  function CheckNemericValue_stdform(e)  
 {         
    	var Alphabet;				
    	//Alphabet = "^[a-zA-Z]+$";				
    	Alphabet ="^[a-zA-Z ]*$" ;				
    	//A-Z or a-z Alphabets only allowed				
    					
    	if (e.search(Alphabet) == -1) 				
    	//	Or				
    	//if (!name.match(Alphabet))				
    	{					
    	/*alert ("Only alphabets are allowed!");*/
    	
    	
         document.getElementById("diverrormsgname").innerHTML ="Only alphabets are allowed!"					
    	return false;		
    	}				
    	else				
    	{					
    	return true;			
    	}
       
 }  
 
 function validate_submit()
  {
     with (document.form)
    {       
            document.getElementById("diverrormsgname").innerHTML="";
            document.getElementById("diverrormsgfax").innerHTML="";
            document.getElementById("diverrormsgmail").innerHTML="";
            document.getElementById("diverrormsgsc").innerHTML="";
            document.getElementById("diverrormsgcontact").innerHTML="";
    
        if (name.value =="")
        {
  
            
             document.getElementById("diverrormsgname").innerHTML="Please fill in your name!";
            name.focus();
             return false
         }
         
           else if (name.value !="" && CheckNemericValue_stdform(name.value)==false)
        {
           
             
            name.value ="";
            name.focus();
            return false;
         }
         
        else if (contact.value =="")
        {
            /*alert("Please fill in your contact number!");*/
           

            document.getElementById("diverrormsgcontact").innerHTML="Please fill in your contact number!";
            contact.focus();
            return false
         }
         
         else if(contact.value != "" && isNaN(contact.value) == true)
         {
            /*alert("Contact number must be numeric!");*/
       
          
            document.getElementById("diverrormsgcontact").innerHTML="Contact number must be numeric!";
            contact.value="";
            contact.focus();
            return false
         }
        
        else if(faxnumber.value != "" && isNaN(faxnumber.value) == true)
         {  
         
            /*alert("Fax number must be numeric!");*/
      
            
            document.getElementById("diverrormsgfax").innerHTML="Fax number must be numeric!";
            faxnumber.value="";
            faxnumber.focus();
            return false
         }
         
        else if (email.value =="")
        {
            /*alert("Please fill in your email!");*/
            
           
            
            document.getElementById("diverrormsgmail").innerHTML="Please fill in your email!";
            email.focus();
             return false
         }
         
         else if (email.value !="" && echeck_stdform(email.value)==false) {
         
        
            
            email.value="";
            email.focus();
            return false
        }
        
       else if(securitycode3.value=="")
       {
            /*alert("Please enter the security code shown!");*/
         
            document.getElementById("diverrormsgsc").innerHTML="Please enter the security code shown!";
            securitycode3.value="";
            securitycode3.focus();
            return false
        }
       
       else if(securitycode3.value!=ImageNo3.value)
       {
            /*alert("Security code does not match!");*/
          
            
            document.getElementById("diverrormsgsc").innerHTML="Security code does not match!";
            securitycode3.value="";
            securitycode3.focus();
            return false
        }
        
        else if (product.value =="")
        {
            /*alert("Please fill the product!");*/
            document.getElementById("diverrormsgprd").innerHTML="Please fill the product!";
            product.focus();
             return false
         }
      
        else if (quantity.value =="")
        {
            /*alert("Please fill in the quntity!");*/
            document.getElementById("diverrormsgqty").innerHTML="Please fill in the quntity!";
            quantity.focus();
             return false
         }
      
       
        else{
            return true
        }

      }
    
  }
