Convertir a mayúscula tras abandonar el input

Podría darse el caso de que queremos que los usuarios que se registren en nuestras Web se guarden sus nombres en la base de datos en mayúsculas o minúsculas.

En este artículo vamos mostrar una forma de pasar a mayúsculas los datos introducidos al abandonar el input.

Este efecto lo podemos lograr con el evento onblur de HTML de la siguiente forma:

<input type="text" id="fname" onblur="upperCase()">

En este caso, lo que hace el efecto onblur es llamar a la función upperCase() que tenemos previamente declarada dentro de la etiqueta <head>. La función se encarga de pasar a mayúsculas el contenido depositado en el input.

<script type="text/javascript">
function upperCase() {
   var x=document.getElementById("fname").value
   document.getElementById("fname").value=x.toUpperCase()
}
</script>

En esta función lo que estamos haciendo es recoger el valor del input con id=»fname» y cambiar su valor a mayúsculas con la función toUpperCase() de javascript.

Ver ejemplo en funcionamiento

 

Autor
Escrito por Jose Aguilar - Director ejecutivo y tecnológico en JA Modules. Experto programador PrestaShop y Experto programador WordPress.
Te ha servido? Valora esta entrada!
(7 votos, promedio: 5 de 5)
Comparte en las redes sociales
¿Buscas trabajo de programador?

14 respuestas a “Convertir a mayúscula tras abandonar el input”

  1. URL dice:

    … [Trackback]…

    […] Find More Informations here: jose-aguilar.com/blog/uppercase-onblur/ […]…

  2. Cole dice:

    I gotta bookmark this web site it seems very useful very helpful

  3. four micro onde pas cher dice:

    I have learn some just right stuff here. Definitely worth bookmarking for revisiting. I wonder how much attempt you put to make the sort of magnificent informative web site.

  4. Henry dice:

    Keep up the great piece of work, I read few content on this website and I think that your blog is really interesting and has lots of wonderful information.

  5. The Auto SMS System dice:

    Real nice pattern and excellent content , hardly anything else we want : D.

  6. most popular music downloads dice:

    I know this is really boring and you are skipping to the next comment, but I just wanted to throw you a big thanks – you cleared up some things for me!

  7. Claire dice:

    Regards for helping out, good info .

  8. Noriko Jou dice:

    I simply want to say I am just all new to blogging and actually savored this page. Almost certainly I’m likely to bookmark your website . You really come with perfect articles and reviews. Cheers for revealing your blog.

  9. chaussure de foot dice:

    Some truly superb info , Glad I found this. «No men can be lords of our faith, though they may be helpers of our joy.» by John Owen.

  10. healthy meal plan dice:

    I have not checked in here for a while since I thought it was getting boring, but the last few posts are great quality so I guess I will add you back to my everyday bloglist. You deserve it my friend 🙂

  11. Charles Tweedie dice:

    As I website possessor I conceive the written content here is really good , appreciate it for your efforts.

  12. Xuan Coswell dice:

    I’ve learn a few just right stuff here. Certainly worth bookmarking for revisiting. I wonder how a lot effort you place to create this type of great informative site.

  13. bola tangkas dice:

    As I website owner I believe the written content here is real fantastic , thanks for your efforts.

  14. Charlie Imparato dice:

    I dugg some of you post as I cogitated they were handy extremely helpful

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.