﻿function SetMaxLength(obj, limit) 
{
	if (obj.value.length > limit) 
	{
		obj.value = obj.value.substring(0, limit);
	} 
}

//added wfp
//returns empty string if not a number
//accepts negative
function IsNumber(obj, returnEmpty)
{
    var rx = new RegExp(/^[+-]?(?:\d+[.,]?\d*|\d*\.?\d+)$/); //note i'm allowing . or , since in denmark and other countries , is the decimal separator
    var match = rx.exec(obj.value);
    if(match==null) //no match
    {
        if(returnEmpty)
            obj.value = '';
        else obj.valueOf = '0';
        
        return false;
    }
    
    return true;
}
