Results 1 to 2 of 2

Thread: Get focused element in a form

  1. #1
    Sencha User
    Join Date
    Apr 2008
    Posts
    141

    Default Get focused element in a form

    Hey

    Is there a way to get focused element in a form ?

    Regards

    Armnado

  2. #2
    Sencha User sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,335

    Default get active element of your document

    Hi!

    Use document.activeElement, it is supported in all major browsers.

    For more details on document.activeElement browser compatibility, check this https://developer.mozilla.org/en/DOM..._compatibility


    If You are not still getting document.activeElement in your form, try to do following:-

    Code:
    if (!document.activeElement) { 
        //Step 1:- Add a "focus" event handler to all fields .
        //Step 2:- Record the last-focused field in a variable. 
        //Step 3:- Add a "blur" handler to clear the variable upon a blur event for the last-focused field.
    }
    Last edited by sword-it; 24 May 2012 at 10:52 PM. Reason: misspelling
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •