Format Match and type check for input field

Hello I have a data variable with a index and phone number as properties, both of type number.
In a linked page with a form, How can I make sure the user will insert a type number for both? Also is it possible force the user to insert the phone number with the format “xxx-xx-xxxx” ?

I tried to use a IF condition in the form page flow where !IS_NUMBER(INDEX) goes to an alert message, but it does not seem to be working. Thanks


I’m guessing you’re using input fields? Everything written into an input field will be text by default, so when saving it to the data variable you’ll have to use NUMBER(..) for the input value. However, if you want to use the “-” format in the phone number, you might have to change the number property to text. To make sure it’s a number, can you use set the Keyboard type of the input field to phone-pad, so the user only has access to numbers when writing. Here’s more about input validation if these examples could help.

Hmm to force the format, it’s a bit tricky. Here’s some options I tried:

I bound a page variable number to the input field value and added a Receive event node to the logic canvas and set it to page variable number has changed. After that I set the following flow and formula:

So the formula being:
IF(LENGTH(pageVars.number) == 3, RIGHT_PAD(pageVars.number, 4, "-"), IF(LENGTH(pageVars.number) == 7, RIGHT_PAD(pageVars.number, 8, "-"), pageVars.number))

This works fine and automatically appends a “-” when needed, the only issue is if the user mistypes and tries to erase the number, it won’t allow you to erase past the “-”.

Another option could be to use the primitive input component, and add the “-” when the user stops typing and focuses out of the input field, there we can use the Component OnBlur event:

The formula in the set page variable is the following:
JOIN(INSERT_ITEM_AT(SPLIT(pageVars.number, ""), 4, "-"), "")

And you can add another Set page variable node after the first one to insert the second “-”.

Sry sir , I’m the beginner for this. What about the text one? I mean I try to type in preview app but it’s default by when I type it’s automatic backspace and I still wondering why? please reply me asap. Thanx u so much sir.