// checks if field value is present or not
function validate_required(value)
{
    if (value != '' && value)
    {
        return true;
    }
    else
    {
        return false;
    }
}


// Check zipcode, based on the country's demog code
function validate_postalcode(postal_code, country_demog_code) {
    switch (country_demog_code) {
        case "630":
            postal_code_regex = /^([0-9]{5})(?:[-\s]*([0-9]{4}))?$/;
            break;
        case "667":
            postal_code_regex = /^([A-Z][0-9][A-Z])\s*([0-9][A-Z][0-9])$/;
            break;
        default:
            postal_code_regex = /^(?:[A-Z0-9]+([- ]?[A-Z0-9]+)*)?$/;
    }
    
    return postal_code_regex.test(postal_code);
}


// Check Email validity
function validate_email_address(email)
{
   var email_pattern = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(email_pattern.test(email) == false) 
   {
       return false;
   }
   else 
   {
       return true;
   }
}