
01/10/2008, 10:52
|
| | Fecha de Ingreso: junio-2008
Mensajes: 63
Antigüedad: 16 años, 9 meses Puntos: 0 | |
Respuesta: TextArea Formato YA PUDE!!
Ya pude construir un script, para que te convierta en mayusculas la primer letra y la que esta despues de un punto, con su respectivo espacio.
Aqui dejo el script:
function formatogram(nombre)
{
//var mombre = document.getElementById('platica_alta').value;
//alert(nombre);
cad='.';
cad2='*';
//alert(cad);
//alert(cad2);
pos=nombre.indexOf(cad);
//alert(pos);
uno=nombre.substr(0,1); //alert(uno);
longitud = nombre.length;
//alert(longitud);
dos=nombre.substr(1, nombre.length); //alert(dos);
uno = uno.toUpperCase(); //alert(uno);
//$arreglo=explode('.',nombre);
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;
tmpStr = nombre.toLowerCase();
alert(tmpStr);
strLen = tmpStr.length;
alert(strLen);
if (strLen > 0)
{
for (index = 0; index <= strLen; index++)
{
if (index == 0)
{
alert(index);
tmpChar = tmpStr.substring(0,1).toUpperCase();
alert(tmpChar);
postString = tmpStr.substring(1,strLen);
tmpStr = tmpChar + postString;
alert(tmpStr);
}
else
{
alert(index);
tmpChar = tmpStr.substring(index, index+1);
alert(tmpChar);
alert(index);
alert(strLen);
if (tmpChar == "." && index < (strLen-1))
{
alert("IF PUNTO");
tmpChar = tmpStr.substring(index+1, index+2);
alert(tmpChar);
if (tmpChar != " " && index < (strLen))
{
var salto = event.keyCode;
alert(salto);
if (tmpChar == salto && index < (strLen))
{
alert("SALTO");
tmpChar = tmpStr.substring(index+1, index+3).toUpperCase();
alert(tmpChar);
preString = tmpStr.substring(0, index+1);
alert(preString);
postString = tmpStr.substring(index+2,strLen);
alert(postString);
tmpStr = preString + ' ' +tmpChar + postString;
alert(tmpStr);
strLen = strLen+1;
}
else
{
alert("SIN ESPACIO");
tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
alert(tmpChar);
preString = tmpStr.substring(0, index+1);
alert(preString);
postString = tmpStr.substring(index+2,strLen);
alert(postString);
tmpStr = preString + ' ' +tmpChar + postString;
alert(tmpStr);
strLen = strLen+1;
}
}
else
{
alert("CON ESPACIO");
alert(index);
tmpChar = tmpStr.substring(index+2, index+3).toUpperCase();
alert(tmpChar);
preString = tmpStr.substring(0, index+1);
alert(preString);
postString = tmpStr.substring(index+3,strLen);
alert(postString);
tmpStr = preString + ' ' +tmpChar + postString;
alert(tmpStr);
strLen = strLen+1;
}
}
}
}
}
document.getElementById('platica_alta').value = tmpStr;
}
AHORA TENGO EL SIGUIENTE PROBLEMA:
Alguien sabe como detectar un salto de linea, para que automaticamente me ponga la primer letra en Mayuscula...
Es lo unico que me falta, detectar un salto de linea... |