﻿// JScript File

window.onload = initializePage;

function initializePage()
{
    document.getElementById('aspnetForm').onsubmit = validateDownloadForm;
}

function validateDownloadForm()
{ 
    var validate
    var x1 = document.getElementById('ctl00_ctl00_ContentPlaceHolder1_downloadPagesContent_txtName');
    var x2 = document.getElementById('ctl00_ctl00_ContentPlaceHolder1_downloadPagesContent_txtEmail');
    var x3 = document.getElementById('ctl00_ctl00_ContentPlaceHolder1_downloadPagesContent_cboOccupation');   
    
    validate = true;
    
        if (checkemail(x2) == false)
            {
            document.getElementById('emailError').style.display = 'inline';
            document.getElementById('emailError').innerText = 'Invalid e-mail address';
            document.getElementById('emailError').textContent = 'Invalid e-mail address';
            validate = false;
            }
        else{
            document.getElementById('emailError').style.display = 'none';
            }
            
        if (x1.value.length == 0)
            {
            document.getElementById('nameError').style.display = 'inline';
            validate = false;
            }
        else
            {
            document.getElementById('nameError').style.display = 'none';
            }
            
        if (x3.value == '(Select One)')
            {
            document.getElementById('occupationError').style.display = 'inline';
            validate = false;
            }
        else
            {
            document.getElementById('occupationError').style.display = 'none';
            }
         
    return validate;
}