﻿// JScript File

function IsNumericDimensions(oSrc, args)
{
    var blnResult = true;
    var h = document.getElementById('txtHeight');
    var w = document.getElementById('txtWidth');
    var d = document.getElementById('txtDepth');

    if(h.value != '')
    {
        if(!CheckNumericValue(h.value))
            blnResult = false;
    }
        
    if(w.value != '')
    {
        if(!CheckNumericValue(w.value))
            blnResult = false;
    }
        
    if(d.value != '')
    {
        if(!CheckNumericValue(d.value))
            blnResult = false;
    }    

    args.IsValid = blnResult;
}

function IsNumericQuantity(oSrc, args)
{
    var blnResult = true;
    var q = document.getElementById('txtQuantity');

    if(q.value != '')
    {
        if(!CheckNumericValue(q.value))
            blnResult = false;
    }

    args.IsValid = blnResult;
}

function CheckNumericValue(strString)
{
    var strValidChars = "0123456789.-";
    var strChar;
    var blnResult = true;

    if (strString == '')
        return true;
        
    if (strString.length == 0) 
        return true;

    //  test strString consists of valid characters listed above
    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            blnResult = false;
        }
    }
      
    return blnResult;
}