﻿function StringControl(obj, length, caplock)
{
    if (obj.value.length >= length){
		window.event.keyCode = 0;
	}
	
	if (caplock){
	    if (window.event.keyCode > 96 && window.event.keyCode < 123)
		    window.event.keyCode = window.event.keyCode - 32;
	}
}

function NumberControl(obj, evt, length)
{
    if (obj.value.length >= length){
		window.event.keyCode = 0;
	}
	
    var unicode=evt.charCode? evt.charCode : evt.keyCode
    
    if (unicode != 8){ //if the key isn't the backspace key (which we should allow)
        if (unicode < 48 || unicode > 57) //if not a number
        return false //disable key press
    }
}

function DecimalControl(obj, evt, length)
{
    if (obj.value.length >= length){
		window.event.keyCode = 0;
	}
	
    var unicode=evt.charCode? evt.charCode : evt.keyCode
    
    if (unicode != 8){ //if the key isn't the backspace key (which we should allow)
        if (unicode < 46 || unicode > 57 || unicode == 47) //if not a number
        return false //disable key press
    }
}