﻿function validate_option1()
{
    var alertText = "To calculate freight offset you must:\r\n";
    var option1IsValid = true;
    if (document.getElementById)
    {
        var numericExpression = /^[0-9]*$/;
        var numericExpressionReq = /^[0-9]+$/; // one or more numeric value
        
        // validate the fuel type for required value
        if (document.getElementById('ddlOpt1FuelType').value == "") {
            option1IsValid = false;
            alertText += " - Select the fuel type used\r\n";
        }   
        
        // validate number of units for numeric value > 0
        if (!document.getElementById("txtOpt1Units").value.match(numericExpressionReq)) {
            option1IsValid = false;
            alertText += " - Enter number of units used in numeric format\r\n";
        } 	        
        
        // return the option1IsValid, alert user if option1IsValid == false with alertText
        if (option1IsValid) {
            return true;
        } else {
            alert(alertText);
            return false;
        }
    }
}
