Just starting to use this and loving it. I am not a programmer but had self-taught visual foxpro an eon ago. Curious if there is a way to format mask a telephone texbox so that it displays (and, ideally, also accepts input) as above.
TIA
Rose
Hello and welcome.
Are you asking how to force the textbox to display a phone number in a specific format? If so, you could do the format checking and setting based on when an event occurs (eg., lost focus, pressed enter, change).
Please have a look at the docs on events and feel free to share the code you have tried as this may help to make things clearer.
A little late, but for further reference:
-
Import in “native libraries”:
<script src="https://unpkg.com/imask"></script>
-
Add to imports:
from anvil.js.window import IMask
-
Initialize input masker in the constructor:
def __init__(self, **properties):
self.init_components(**properties)
IMask(
anvil.js.get_dom_node(self.input_doc),
{'mask': '000.000.000-00'},
)
IMask(
anvil.js.get_dom_node(self.input_phone),
{'mask': '(00)00000-0000'},
)
Yes, it’s that one.
Working like a charm.
Great! Now I know where to go for documentation. I have a lot of data-entry fields. Formatting would make them much more user-friendly.
Thanks for finding this library.