Javascript Validation on "Phone Number" type!

Javascript Validation on "Phone Number" type!

Ok guys, this is my first post and i will try to explain as best as i can....

Development Scenario:

1 entity with 4 atributes

Entity: Person

Person's Attributes

Id ( obviously )
Name ( type: text )
Age ( type: integer )
Phone Number ( type: phone number )

I have developed a form (3 input widgets) to insert a new Person.

the Name input widget is assigned to a Text type variable.
the Age input widget is assigned to an Integer type variable.
the Phone number input widget is assigned to a Phone Number type variable.

I am able to use the validation for the Age field properly. When someone tries to fill the Age field with non-numeric characters, the system returns the default message "Integer Expected!".

So far so good.

But now i want to do the same thing for the Phone Number and i did exactly the same. I just assign the input widget to get its input variable into a variable of type "Phone Number" and it still allows non-numeric characters and no message pops up.

if i look at the sourcecode, the validator for "Phone Number" is there, but it doesn't work!

I know that this works for phone number as well because i have seen on the Help of Service Studio and on the default messages i see "Phone Number Expected!" as well...

Can anyone help me?

Hi Pedro,

First of all let me welcome you to the community and thank you very much your effort to be clear.

Let me to try to be it as well. The "Phone Number" type is actually an alias to the "Text" data type.
This is because international phone numbers often have the "+" sign.

If you want to assure that only numeric chars are entered you can:
  • Use the TextToIntegerValidate() function and an If tool in a Screen Action.
  • A simpler option would be to use the Integer data type on that attribute.
I hope this helps, but let us know if you need any more help.

Tiago Simoes
Thanks for the reply Tiago.

I just tried those methods that you indicated and they prevent me of using the '+' and space characters and i want to allow numbers, '+' and space...

i don't want to use custom javascript functions made by myself because some of the fields are already using the outsystems validation and i can't change that... (i am resuming someone else's work)

i must use the same outsystems validation for the "Phone Number" field!
...or you could use the Extension Text that has a Regex_Search action.

This would give you more versatility. See the attached oml for an example.