function input_text_length(input, nombre, minima, maxima)
{
	var length = longitudReal(input.value);
	if (length < minima) {
		if (minima > 1) {
			addGlobalErrorMessage(input,"MIN_CHARS",nombre,minima);
		} else {
			addGlobalErrorMessage(input,"NO_VACIO",nombre);
		}
		return false;
	}

	if (length > maxima) {
		diferencia = length - maxima;
		addGlobalErrorMessage(input,"MAX_CHARS",nombre,maxima,diferencia);
		return false;
	}
	return true;
}

function longitudReal(text) {
	var length = 0;
	for (var i = 0; i < text.length; ++i) {
		// If the browser interprets carriage return as character 10, instead of the pair 13 + 10, increment length.
		// This is necessary because Java will interpret carriage return as two characters anyway; at least in Windows.
		if (text.charCodeAt(i) == 10 /* carriage return */ && (i == 0 || text.charCodeAt(i - 1) != 13 /* line feed */)) {
			++length; // The extra \r some browsers don't count.
		}
		++length;
	}
	return length;
}
