JavaScript
  Home arrow JavaScript arrow Page 2 - JavaScript Events
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

JavaScript Events
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2007-11-26

    Table of Contents:
  • JavaScript Events
  • OnBlur
  • OnChange
  • OnClick
  • OnDblClick

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    JavaScript Events - OnBlur


    (Page 2 of 5 )

    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:


    <html>

    <head>

    <script type="text/javascript">

    function upperCase()

    {

    var x=document.getElementById("firstname").value

    document.getElementById("firstname").value=x.toUpperCase()

    }

    function uCase()

    {

    var x=document.getElementById("lastname").value

    document.getElementById("lastname").value=x.toUpperCase()

    }

    </script>

    </head>

    <body>

    First Name: <input type="text" id="firstname" onblur="upperCase()"><br />

    Last Name: <input type="text" id="lastname" onblur="uCase()"><br />

    <input type="submit" value="Submit Info" id="sub">

    </body>

    </html>

    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.


    Supporting HTML tags: <a>, <acronym>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <button>, <caption>, <cite>, <dd>, <del>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <frame>, <frameset>, <h1> to <h6>, <hr>, <i>, <iframe>, <img>, <input>, <ins>, <kbd>, <label>, <legend>, <li>, <object>, <ol>, <p>, <pre>, <q>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

    Supporting Javascript Objects: button, checkbox, fileUpload, layer, frame, password, radio, reset, submit, text, textarea, window

    More JavaScript Articles
    More By James Payne


       · Hey, welcome to my article on Javascript Events, where we discuss some of the Events...
     

    JAVASCRIPT ARTICLES

    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...
    - Dynamically Generate a Selection List in a R...
    - Intergrate DWR into Your Java Web Application
    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT