Focusing on a textbox depending on which element is getting blurred

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harig
    New Member
    • Jul 2007
    • 10

    #1

    Focusing on a textbox depending on which element is getting blurred

    hi all..

    how do i focus a textbox from a javascript

    i'e)
    [code=html]<input type="text" size='50' name="txt1" maxlength='254' value="" onblur="checkDi r()">
    <input type="text" size='50' name="txt2" maxlength='254' value="" onblur="checkDi r()">[/code]


    i've a funtion in js called checkDir()... and i've more text boxes... i need to focus the text box from where i get the control

    suppose if my control goes from text2 i need to set focus on textbox2.. how do i do it .... anyone help me out of dis
    Last edited by acoder; Sep 5 '07, 10:32 AM. Reason: Added code tags
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by harig
    hi all..

    how do i focus a textbox from a javascript

    i'e)
    <input type="text" size='50' name="txt1" maxlength='254' value="" onblur="checkDi r()">
    <input type="text" size='50' name="txt2" maxlength='254' value="" onblur="checkDi r()">


    i've a funtion in js called checkDir()... and i've more text boxes... i need to focus the text box from where i get the control

    suppose if my control goes from text2 i need to set focus on textbox2.. how do i do it .... anyone help me out of dis

    So us your JavaScript code.
    And next please use Code Tags.
    I mean follow the Post Guidelines while you do Post.

    Kind regards,
    Dmjpro.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Pass a reference to the text box in CheckDir() :
      [CODE=javascript]CheckDir(this);[/CODE] then in the function:
      [CODE=javascript]function CheckDir(textbo x) {
      ...
      textbox.focus() ;
      }[/CODE]
      PS. please use code tags when posting code, not bold tags. It makes it easier to read.

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).

        Comment

        Working...