function allowOnlyDigitsAndOneDot(thisEvent,val){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (thisEvent) keycode = thisEvent.which;
	//alert("keycode: " + keycode);
	//alert("val="+val);//val contine ce text era inainte de apasarea tastei

	//keycode==8 is backspace and keycode==0 is delete
	if (keycode==8 || keycode==0) return true;
	
	if (keycode==46)
	{
	var index=val.indexOf(".");
	if (index!=-1) {alert("Only one \".\" is allowed!");return false;}
	else return true;
	}

	
	if (keycode<48 || keycode>57)
	        {
		     alert("Only digits are allowed!");
	         return false;
	        }
	        
	return true;	
}

function allowOnlyDigitsAndOneDotMaxDecimals(thisEvent,val,maxDecimals){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (thisEvent) keycode = thisEvent.which;
	//alert("keycode: " + keycode);
	//alert("val="+val);//val contine ce text era inainte de apasarea tastei

	//keycode==8 is backspace and keycode==0 is delete
	if (keycode==8 || keycode==0) return true;
	
	if (keycode==46)
	{
	var index=val.indexOf(".");
	if (index!=-1) {alert("Only one \".\" is allowed!");return false;}
	else return true;
	}

	
	if (keycode<48 || keycode>57)
	        {
		     alert("Only digits are allowed!");
	         return false;
	        }
	        
	//if there are decimals, than it cannot be more than maxDecimals decimals
	var index=val.indexOf(".");
	if (index!=-1) {
		var fractionPart = val.substring(index+1);
		//+1 is because the length of fraction part is taken before key press and the last letter is not taken into consideration
		if (fractionPart.length + 1 > maxDecimals) {
			alert("The value must have maximum "+maxDecimals+" decimals!");
			return false;
		}
	}
	
	return true;	
}

function allowOnlyDigits(thisEvent,val){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (thisEvent) keycode = thisEvent.which;
	//alert("keycode: " + keycode);
	//alert("val="+val);//val contine ce text era inainte de apasarea tastei

	//keycode==8 is backspace and keycode==0 is delete
	if (keycode==8 || keycode==0) return true;
	
	if (keycode<48 || keycode>57)
	        {
		     alert("Only digits are allowed!");
	         return false;
	        }
	     
	//if there are decimals, than it cannot be more than maxDecimals decimals
	var index=val.indexOf(".");
	if (index!=-1) {
		var fractionPart = val.substring(index+1);
		//+1 is because the length of fraction part is taken before key press and the last letter is not taken into consideration
		if (fractionPart.length + 1 > 0) {
			alert("The value must have 0 decimals!");
			return false;
		}
	}
	
	return true;	
}

function allowOnlyDigitsAndOtherCharacters(thisEvent,val, allowedCharacterCodesArray){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (thisEvent) keycode = thisEvent.which;
	//alert("keycode: " + keycode);
	//alert("val="+val);//val contine ce text era inainte de apasarea tastei

	//keycode==8 is backspace and keycode==0 is delete
	if (keycode==8 || keycode==0) return true;	
	
	if (allowedCharacterCodesArray != null) {
		var i=0;
		for(i=0; i<allowedCharacterCodesArray.length; i++) { 
			var allowedCharacterCode = allowedCharacterCodesArray[i];
			if ( keycode == allowedCharacterCode) return true;
		}
	}
	
	if (keycode<48 || keycode>57)
	        {
		     alert("Only digits are allowed!");
	         return false;
	        }
	
	return true;	
}
