In our last article we left off with a glimpse of JavaScript Events. In this tutorial we are going to go through each one and learn how to use them to create more dynamic web sites. So slap on your seat belts and get your helmets ready. This is gonna be an action-packed episode.
When an object loses focus, it becomes blurred. OnBlur triggers when this happens. Let’s say you have someone filling out a form and you want everything to look uniform. I know when I fill out a form I leave everything lowercase. Maybe though, it is easier for you if everything is uppercase. We can use the OnBlur function to change any text a user puts into the form into uppercase as soon as the text box loses focus. Here is the code:
The above code creates two input boxes: one for the first name, another for the last name. When the user inputs text into one of the text boxes and moves on to the next (or when either text box loses focus), whatever text is in the text box becomes capitalized. The submit button in this instance doesn’t do anything but sit there looking pretty.