JavaScript Events (Cont.)


onFocus, onBlur, and onChange
The onFocus, onBlur, and onChange events are often used in combination with validation of form fields. Below is an example of how to use the onChange event, which executes JavaScript code when a change event occurs; that is, when a select, text, or textarea field loses focus and its value has been modified.




   

The lowerCase() function will be called whenever the user changes the content of the field. The function converts the uppercase letters in the Unix shell command to lowercase letters before the command is executed:

Demonstration
The following demonstration shows how the script of HTML and JavaScript is displayed on the Web.

     





      “What’s the difference between a refrigerator and an elephant?”    
      “What?”    
      “Are you stupid? Like, everything.”    
      — Nikki Glaser