Is there a way in a Web app to show a prompt IN the field like the behavior of the title when starting a new conversation here.
Essentially you gain focus of the field and there is a prompt displayed. When you start typing the prompt disappears and is replace by your characters. If you backspace to an empty field the prompt returns when the last character is erased.
This cannot be done effectively with the TextChanged event because it is too slow.
I do this in most of my web fields using the GotFocus and LostFocus events.
Here’s pseudocode for the GotFocus event which triggers when they enter the field and blanks out the prompt so they can start typing:
if me.text="[your field prompt here]" then
me.text=""
me.style=StandardTextFieldFilled
end if
For the LostFocus event, it’s something like this:
if trim(me.text)="" then
me.text="[your field prompt here]"
me.style=StandardTextFieldPrompt
end if
That’s the basic concept. In my apps, I usually make those routines into global methods called from all the GotFocus/LostFocus events so that I can make changes in one place and the code isn’t duplicated in every single field.
At one point, I also did something like that using the KeyPressed event, but I think the reason I backed off from that was it seemed excessive to analyze every key press, although it might be worthwhile if you want to catch the Enter/Return key or other special keys anyway.