﻿

//Check for valid numeric values
function IsOnlyNumeric(strString) {
    var strValidChars = "0123456789";
    var strChar;
    var blnResult = 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;
}

function CheckNumeric(ctrl) {
    txt = document.getElementById(ctrl);
    if (txt != null) {
        if (txt.value.length >= 0) {
            if (IsOnlyNumeric(txt.value) == false) {
                txt.value = "";
            }
        }
        if (txt.value != "") {
            document.getElementById("ctl00_ContentPlaceHolderProductSearch_hdnTxtID").value = ctrl;
            document.getElementById("ctl00_ContentPlaceHolderProductSearch_hdnQuantity").value = txt.value;
            document.getElementById("ctl00_ContentPlaceHolderProductSearch_btnSaveQuantity").click();
        }
    }
}

function CheckAllDataGridCheckBoxes(aspCheckBoxID, checkVal) {
    re = new RegExp(aspCheckBoxID);  //generated control name starts with a colon
    for (i = 0; i < document.forms[0].elements.length; i++) {
        elm = document.forms[0].elements[i];
        if (elm.type == 'checkbox') {
            if (re.test(elm.name)) {
                if (elm.disabled == false) {
                    elm.checked = checkVal;
                }
            }
        }
    }
}

function ShowStatus(dv, OrderID, btnBindItem, hdnOrderID, ColorSizeMapID, hdnColorSizeMapID) {
    hdnOrderID = document.getElementById(hdnOrderID);
    hdnOrderID.value = OrderID;
    var hdnColorSizeMapID = document.getElementById(hdnColorSizeMapID);
    hdnColorSizeMapID.value = ColorSizeMapID;
    document.getElementById(btnBindItem).click();
    dv = document.getElementById(dv);
    //Set popup to visible
    dv.style.display = "inline";
}
function OnlyDecimal(ctrl) {
    if (ctrl.value.length >= 0) {
        if (IsDecimal(ctrl.value) == false) {
            ctrl.value = ctrl.value.substring(0, ctrl.value.length - 1);
        }
    }
}

//Check for valid numeric strings
function IsDecimal(strString) {
    var strValidChars = "0123456789.";
    var strChar;
    var blnResult = 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;
}
