Adam Zastawski

My Personal Blog

Simple Auto-Focus script in Tibco GI 3.5.1

Posted by Adam

I realize that what I post regarding General Interface is not going to be rocket science any time soon. Despite that, I figure I had better start posting the things that other developers that are new to GI might find useful.

I was recently developing a sample application as a 'proof of concept' in General Interface and it occurred to my that it would be nice if the form would automatically move focus when all the allowed characters had been entered. This is useful when the user is entering a social security number of telephone number. The cursor automatically jumps to the next textbox saving the user from having to click 'Tab' or clicking over. Here's how I accomplished this.

It all revolves around a convenient feature built into the GI framework called the 'Inc. Change' event on all textboxes. This event only fires when a letter has been added or deleted from the value of the text box.

The following JavaScript is called when capturing the Inc. Change event.

image

Create a form like the one below.

image

Set the maximum characters on the textboxes and set the validation type as well. I've set mine in the sample to 'Number' so that I can make use of another convenient GI feature called 'doValidate()'. You may notice in the JavaScript above that if the user has entered values that cause 'doValidate()' to return false, the background is set to red and the auto-focus behavior does not fire.

Here is the javascript that calls the function above.

autoFocusNext(this, 'tbPhone1');

Happy coding in GI!

AutoFocusNextSample.zip (4.63 kb)

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Posted on: 11/23/2007 at 1:39 AM
Categories: AJAX | Tibco - GI
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

Wednesday, July 23, 2008 1:08 PM