﻿

 


 function ValidateFields()
   {
   
        var name   = document.forms[0]['name'];
        var email = document.forms[0]['email'];
  
    if(name)
    {
        if (name && name.value.length == 0)
        {
            name.style.backgroundColor = "lightyellow";
            name.select();
            window.scrollTo(0,450);
            alert("The name field is compulsary ,please insert your name and re-submit your enquiry, thankyou.");
            return false;
        }
        else 
            name.style.backgroundColor = "white";
       
    }
           
    if(email){    
        if (email.value.length == 0)
        {
            email.style.backgroundColor = "lightyellow";
            email.select();
            window.scrollTo(0,450);
            alert("The email field is compulsary ,please insert a valid email address and re-submit your enquiry, thankyou.");
            return false;
        }
        else 
            email.style.backgroundColor = "white";
        
        //validate the email format is correct
        var regexp =  /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

            
        if ( regexp.exec(email.value) == null)
        {
            email.style.backgroundColor = "lightyellow";
            email.select();
            window.scrollTo(0,450);
            alert("There appears to be something wrong with the email address you have supplied, please check the email address format and re-submit your enquiry, thankyou.");
            return false;
        }
        else{
            email.style.backgroundColor = "white";
        }
        
     }  
        
     return true;
}
