El sitio más completo sobre programación, recursos web y herramientas online para Webmasters
Fecha: 20/01/2003

trim derecha ( TrimRight )

sencilla funcion javascript que se encarga de remover los espacios de la derecha de un string.

Código Javascript


<script type="text/javascript">
function TrimRight( str ) {
var resultStr = "";
var i = 0;
// Return immediately if an invalid value was passed in
if (str+"" == "undefined" || str == null)
return null;
// Make sure the argument is a string
str += "";

if (str.length == 0)
resultStr = "";
else {
// Loop through string starting at the end as long as there
// are spaces.
i = str.length - 1;
while ((i >= 0) && (str.charAt(i) == " "))
i--;

// When the loop is done, we're sitting at the last non-space char,
// so return that char plus all previous chars of the string.
resultStr = str.substring(0, i + 1);
}

return resultStr;
}
</SCRIPT>

trim derecha ( TrimRight ) Categoría: Javascript, Funciones

Compartir trim derecha ( TrimRight ) en Facebook Twitter MySpace del.icio.us fresqui Meneame


Scripts Similares:

» validar numeros con javascript
» funcion isEmail javascript
» funcion isEmail javascript
» reemplazar string script
» trim izquierda ( TrimLeft ) javascript
» validar numeros con javascript
Ver el perfil de Gabriel Marcelo Rodriguez en LinkedIn

Privacidad ּ Publicidad ּ Prensa ּ Premios ּ Colaborar ּ Enlazarnos ּ Mapa del Sitio ּ Aviso legal ּ Boletín ּ Contacto
2001 - 2011 | Sitio Sitio creado y mantenido por Gabriel Marcelo Rodriguez
Hosting de alta calidad a bajo costo Neolo.com.ar