var numberOfSpaces = 0;
var numberOfChar = 0;

/*validazione del prezzo*/
function pricevalidation(e)
{
	//keyCode = explorer; charCode = others
	var unicode = e.charCode ? e.charCode : e.keyCode;
	
	if((unicode != 8) && (unicode != 44)){	//se non č backspace o virgola
		if((unicode < 48) || (unicode > 57)) //se non un numero
			return false;
	}
}

/*validazione textarea se si scrive*/
function onKeyPressLimitLength(e, length)
{
	var unicode = e.charCode ? e.charCode : e.keyCode;

	numberOfChar++;
		
	if(numberOfChar == length)
	{
		alert('Non puoi inviare un messaggio che contiene pių di '+ length +' lettere');
		return false;
	}
}

/*validazione textarea se copia incolla*/
function onChangeLimitLength(obj, length)
{
	var text = obj.value;
	
	if(text.length > length)
	{
		text = text.substr(0, length - 1);
		obj.value = text;
		numberOfChar = length;
		alert('Non puoi inseriro un testo che contiene pių di '+ length +'lettere');
	}
		
	obj.blur();
}

/*validazione titolo*/
function titlevalidation(e)
{
	var unicode = e.charCode ? e.charCode : e.keyCode;

	if(unicode == 32)
	{
		numberOfSpaces++;
	}
		
	if(numberOfSpaces > 5)
	{
		alert('hai a disposizione 6 parole per il titolo');	
		return false;
	}
}