find the control using 'this' parameter in javascript

Posted on 2011-10-25
Last Modified: 2012-05-12
I have two controls (textbox) on a page  having onblur="lineNoMask(this, event);"

In the lineNoMask javascript function, I need to identify which control invokes onblur event.

How can I find the control with 'this' parameter?

Question by:minglelinch
    LVL 74

    Accepted Solution

    Identify it how? Get its id? Inside your function you would just refer to the "id" member:

    function lineNoMask(ctrl)

    Open in new window

    LVL 35

    Expert Comment

    by:Miguel Oz
    this contains a reference to the control that invokes onblur event (this will point to the correct text box), thus use it in your lineNoMask method accordingly.
    function lineNoMask(targetControl)
        //use target control as you see fit
    LVL 1

    Author Closing Comment

    Thanks for the comment.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now