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.
Create a form like the one below.
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)
ecd5b257-dd63-4cdc-bd51-8dc12850ff57|1|4.0