
01/10/2008, 12:12
|
| | Fecha de Ingreso: junio-2008
Mensajes: 63
Antigüedad: 16 años, 9 meses Puntos: 0 | |
Respuesta: TextArea Formato LISTO!!!!
Este es el codigo que utilizo, en un TEXTAREA, al ingresar los datos, con el evento onchange mando llamar esta funcion, enviandole el contenido del textarea que se acaba de capturar.
y el problema del enter(nueva linea) se resolvio con esta funcion:
charCodeAt(index);
Espero que pueda funcionarle a alguien.
PD. Muy pocos aportes ponen eeeeeh, puras dudas y nadie responde
Saludos desde Durango, méxico
function formatogram(nombre)
{
cad='.';
cad2='*';
pos=nombre.indexOf(cad);
uno=nombre.substr(0,1);
longitud = nombre.length;
dos=nombre.substr(1, nombre.length);
uno = uno.toUpperCase();
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;
var
tmpStr = nombre.toLowerCase();
strLen = tmpStr.length;
if (strLen > 0)
{
for (index = 0; index <= strLen; index++)
{
if (index == 0)
{
tmpChar = tmpStr.substring(0,1).toUpperCase();
postString = tmpStr.substring(1,strLen);
tmpStr = tmpChar + postString;
}
else
{
tmpChar = tmpStr.substring(index, index+1);
var cara = tmpStr.charCodeAt(index);
if (cara == 13 && index < (strLen-1))
{
tmpChar = tmpStr.substring(index+1, index+3).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+3,strLen);
tmpStr = preString + ' ' +tmpChar + postString;
strLen = strLen+1;
}
else
{
if (tmpChar == "." && index < (strLen-1))
{
tmpChar = tmpStr.substring(index+1, index+2);
if (tmpChar != " " && index < (strLen))
{
tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+2,strLen);
tmpStr = preString + ' ' +tmpChar + postString;
strLen = strLen+1;
}
else
{
tmpChar = tmpStr.substring(index+2, index+3).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+3,strLen);
tmpStr = preString + ' ' +tmpChar + postString;
strLen = strLen+1;
}
}
}
}
}
}
document.getElementById('platica_alta').value = tmpStr;
} |