CRM 2013 Javacript Validate Integer


Script:

function CheckInteger(Field) {
    var Result = Xrm.Page.getAttribute(Field).getValue();

    if (isInt(Result)) {
        Xrm.Page.getAttribute(Field).setValue(Result);
    }
    else {
        alert("Input is not numeric")
        Xrm.Page.getAttribute(Field).setValue(null);
    }
}

function isInt(value) {
    return !isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10));

}

0 comments: