Nov 25, 2009

Highlight The Active Text Input Fields.

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > JavaScript

Highlight The Active Text Input Fields.

TavoxPeru
Hi, this nice script highlight text inputs fields in your forms, so it will help your visitors to see where they are. Follow this steps to install it:
  1. Paste this code into the CSS section of your HTML document
    CODE
    fieldset {
      width: 350px;
    }

    .textInput,textarea {
      width: 200px;
      font-family: arial;
      background-color: #FFFFFF;
      border: 1px solid #000;
    }

    .inputHighlighted {
      width: 200px;
      background-color: #FFCE31;
      color: #000;
      border: 1px solid #000;
    }

  2. Paste this code into an external JavaScript file named: highlight-active-input.js.js
    CODE
    /* Created by: Alf Magne Kalleland :: www.dhtmlgoodies.com (C) www.dhtmlgoodies.com, November 2005 */

    var currentlyActiveInputRef = false;
    var currentlyActiveInputClassName = false;

    function highlightActiveInput() {
      if(currentlyActiveInputRef) {
        currentlyActiveInputRef.className = currentlyActiveInputClassName;
      }
      currentlyActiveInputClassName = this.className;
      this.className = 'inputHighlighted';
      currentlyActiveInputRef = this;
    }

    function blurActiveInput() {
      this.className = currentlyActiveInputClassName;
    }

    function initInputHighlightScript() {
      var tags = ['INPUT','TEXTAREA'];
      for(tagCounter=0;tagCounter<tags.length;tagCounter++){
        var inputs = document.getElementsByTagName(tags[tagCounter]);
        for(var no=0;no<inputs.length;no++){
          if(inputs[no].className && inputs[no].className=='doNotHighlightThisInput')continue;
          if(inputs[no].tagName.toLowerCase()=='textarea' || (inputs[no].tagName.toLowerCase()=='input' &&

    inputs[no].type.toLowerCase()=='text')){
            inputs[no].onfocus = highlightActiveInput;
            inputs[no].onblur = blurActiveInput;
          }
        }
      }
    }


  3. Paste this code into the HEAD section of your HTML document
    CODE
    <script type="text/javascript" src="highlight-active-input.js.js"></script>

  4. Paste this code into the BODY section of your HTML document
    CODE
    <form method="post" action="#">
    <fieldset>
    <legend>Highlight active input</legend>
    <table>
      <tr>
        <td><label for="name">Name:</label></td>
        <td><input class="textInput" type="text" name="name" id="name"></td>
      </tr>
      <tr>
        <td><label for="email">E-mail:</label></td>
        <td><input class="textInput" type="text" name="email" id="email"></td>
      </tr>
      <tr>
        <td><label for="comment">Comments:</label></td>
        <td><textarea id="comment" name="comment" rows="3"></textarea></td>
      </tr>
      <tr>
        <td colspan="2">
          <input type="submit" onclick="return false" value="Submit">
        </td>
      </tr>
    </table>
    </fieldset>
    </form>

  5. Paste this code at the bottom of your HTML document
    CODE
    <script type="text/javascript">
    <!--
      initInputHighlightScript();
    //-->
    </script>
Best regards,

 

 

 


Comment/Reply (w/o sign-up)

Arbitrary
I've seen something of the sort before on Dynamic Drive. Its just that the particular script I saw didn't allow you to attach it in an external JavaScript -- instead, you had to repaste the Javascript snippet in every single HTML document you wanted to use, which turned out to be quite a hassle. So this is a nice improvement on that.

Highlighting forms can definitely be very useful, especially on a form with many boxes to fill out. It makes it easier to figure out which boxes you have yet to fill out and which ones you have already filled out. Speaking of checking empty boxes, it might be nicer if there was a script that highlighted missing fields as the user moved on to the next field. For instance, suppose I filled out first name and then date but neglected to fill out last name, right when I click in the date field, the script should highlight the last name field and tell me I missed it. That makes it a lot better than last minute reminders after I have already filled out the form.

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : highlight, active, text, input, fields

  1. Vertical Text
    kinda OLD but amazing (1)
  2. Add Text To Textarea
    I suppose it uses DOM and JavaScript?? (6)
    I am working on a web "application" thing that allows you to click a button to add text to a
    textarea. Similar to this forum when you click the BOLD button and it puts in {b}{/b} with the
    square brackets. I want a similar function like that. Also, I want it to add wherever the cursor is,
    not at the end. And after adding the thing, the cursor should be in between the tag or whatever that
    was added. All the extra stuff are extra priorities. For now I would like to get something that
    inserts text on click. The thing I came up with is: HTML html > head > text/javasc....
  3. Status Bar Effect
    Have your own text running in the status bar (5)
    Insert this code into the head of your page and the second script in the body tag of your page
    CODE var speed = 50 var pause = 2000 var timerID = null var bannerRunning = false var ar = new
    Array() ar = "This template was designed by solutions4u and for more templates please do visit
    www.solutions4u.co.nr" //Change var www.DesignerWiz.com bannerRunning message var currentMessage = 0
    var offset = 0 function stopBanner() {     if (bannerRunning)     clearTimeout (timerID)
        bannerRunning = false } function startBanner() {    stopBanner()     showBanner() } functi....
  4. Automatic Title/status Text Rotation!
    Change the text in you Title Bar and Status Bar after a preset Interva (0)
    Copied from http://www.cgiscript.net/cgi-script/csNews...wone&id=57&op=t QUOTE Below is the
    code required to rotate the text used in the title bar and status bar QUOTE CODE var
    default1 = "defautl title"; // only shown once at page load var text1 = "title2"; var text2 = "title
    3"; var text3 = "title 4"; var changeRate = 2000; // 1000 = 1 second var messageNumber = 0;
    function changeStatus() {   if (messageNumber == 0) {      window.status=default1;     
    document.title=default1;     }   else if (messageNumber == 1) {      window.status=text1;    ....
  5. Javascript: Text To Texbox And Back To Text
    (3)
    i need some help i want to create a thing where when some one double clicks a certain text it
    changes into a texbox where they can edit the text and the they double click and it changes into the
    test they just typed in. I have found this function in javascript that does some of it but i needs
    to be simplified CODE "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Span to
    Text Box - Demo - DOM /* © John Davenport Scheuer */ function exchange(el){ var
    nodeI=el.parentNode, inputC=document.createElement('input'), text=el.innerHTML; el.style.f....
  6. Javascript For Text Color Swap
    (11)
    Just looking for how I can make a text link change color onmouseover and onmouseout, similar to an
    image swap. Any help on this would be appreciated. Thanks!....

    1. Looking for highlight, active, text, input, fields

See Also,

*SIMILAR VIDEOS*
Searching Video's for highlight, active, text, input, fields
advertisement



Highlight The Active Text Input Fields.

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com