Validation: numbers entered must start with 6, 8, or 9

In an input field (of “number” type), how do you ensure that numbers entered must start with 6, 8, or 9?

You can do


Substr(IntegerToText(number), 0, 1)


To get the first digit

Solution

If your goals is only validation then regex is your friend:

https://refiddle.com/refiddles/5cbef8db75622d10f36f0000

If you truly wish to prevent people from entering it, input masks is a good one, though users can go around that by being sneaky and changing your html. Thus you should always be validating again on the server side just to be sure.

Solution

Hugo Duarte wrote:

https://www.outsystems.com/forge/component-overview/647/custom-input-masks


How do I ensure that numbers entered must start with 6, 8, or 9?

YS Yeo wrote:

Hugo Duarte wrote:

https://www.outsystems.com/forge/component-overview/647/custom-input-masks


How do I ensure that numbers entered must start with 6, 8, or 9?


AdvancedOptions use RegEx you can have what you want there:

  - MaskText - from Custom Masks widget regex code in AdvancedOptions Example: {regex:'^([A-Za-z0-9]+[-?])+([A-Za-z0-9])+$', placeholder: '' }

Try to search on https://regexr.com/

Your requirement seems to be very simple.

Hope it helps.

Joey Moree wrote:

If your goals is only validation then regex is your friend:

https://refiddle.com/refiddles/5cbef8db75622d10f36f0000

If you truly wish to prevent people from entering it, input masks is a good one, though users can go around that by being sneaky and changing your html. Thus you should always be validating again on the server side just to be sure.

I posted a working regex a few posts back.