﻿
function disableBackspace() {
    if (typeof window.event != 'undefined')
        document.onkeydown = function () {
            if (event.srcElement.tagName.toUpperCase() != 'INPUT' && event.srcElement.tagName.toUpperCase() != 'TEXTAREA')
                return (event.keyCode != 8);
        }
    else
        document.onkeypress = function (e) {
            if (e.target.nodeName.toUpperCase() != 'INPUT' && event.srcElement.tagName.toUpperCase() != 'TEXTAREA')
                return (e.keyCode != 8);
        }
    }

function formatNumber(num, prefix) {
    prefix = prefix || '';
    num += '';
    var splitStr = num.split('.');
    var splitLeft = splitStr[0];
    var splitRight = splitStr.length > 1 ? '.' + splitStr[1] : '';
    var regx = /(\d+)(\d{3})/;
    while (regx.test(splitLeft)) {
        splitLeft = splitLeft.replace(regx, '$1' + ',' + '$2');
    }
    return prefix + splitLeft + splitRight;
}

function unformatNumber(num) {
    return num.replace(/([^0-9\.\-])/g, '') * 1; 
   }
