Web TextField Formatting

Been doing nothing but desktop apps ever since I started with XOJO two years ago. Even though I have the Pro license, I never touched anything with the Web Edition (WE) until just now. It’s a learning process and I’m trying to adjust to the differences between the two versions. The first one that should be easy, but I must be missing something in searching the Forum and/or Google in general, is formatting text fields. In desktop apps, I just use Format and Mask to get anything I need formatted (e.g., currency, specific number of decimal places displayed, etc. etc. etc.). I see where the Format command (and Mask) doesn’t exist in WE, so how do I go about taking a user’s input from a web text field and doing the same formatting tasks? For instance, if a user entered “15.2738”, how would I display only “15.27” if I wanted a currency format? What simple thing am I missing?

This reacts like Format, when the TF looses focus :

Sub LostFocus() me.text = format(val(me.text),"#,###.00") End Sub

You will need to remove commas when the control gains focus again so the value does not get warped.

You can probably emulate Mask with TextChange, but on the web it maybe kind of sluggish.

Thank you, Michel … as always, you’re spot on and timely to boot!

Turns out I was close with one thing I had tried in the LostFocus event:

me.Text = Format(me.Text, "\\$###,##0.00")

But it was giving me “incorrect parameter” error … which I now see why with the “val” statement you added.

Your approach does the trick … thanks!
Now on to the next chunk of WE education ^^