314
Views
9
Comments
Solved
Input Number type Long Integer
Question

Hi Guys,


I can't share the OML because I'm from the company, so I'll try to explain.


I have a field with input Number, but the variable of that field in the table is of type Long Integer. I need to check if the user is typing numbers from 1 to 9 for example:

Allow: 123456789 or empty field " "

disallow: 123 or 1 or 0

I'm using an if where I use a Length (input variable) >=1.

but I'm having a problem, if the user just types "0" it accepts.

2018-10-29 08-31-03
João Marques
 
MVP
Solution

Hi Fabiano,


I would suggest using a Mask and make use of RegEx (Regular Expression) patterns.

I would use the Input Mask Reactive forge asset, and would use the InputPatternMask


I would use the pattern (^(?!0$))(^(?!1$))(^(?!123$))((\d)+| )

This pattern basically says that it does not allow a 0, nor a 1, nor a 123 and accepts any number of digits or a space.


Kind Regards,
João

UserImage.jpg
Fabiano Silva

In this case, I can let the user enter any sequence, including starting with "0", my only restriction is that if the user enters a number in the field, this sequence must have size 9. I used the expression ^[0-9]{9 }, but it is not accepting if the sequence starts with "0"

2018-10-29 08-31-03
João Marques
 
MVP

Hi Fabiano,


I am getting confused with your requirements for the field.

From what I understand, your field should contain either 9 digits or left empty, right?

In that case, your pattern should be ((\d){9}|^$)

A brief explanation on the patterns:

  • \d indicates a digit
  • {9} indicates it has to be 9-char length
  • | indicates an or
  • ^ indicates the beginning of the string and $ the end. Both together without anything in the middle, means an empty string


Cheers,
joão

UserImage.jpg
Fabiano Silva


Examples of strings that can be 

typed:012346542

687593842" "

cannot accept:

0

235

23475098 = eight digits

2023-10-21 19-42-11
Tousif Khan
Champion

Hello

As you have mentioned you are using the If condition where the condition is:
 Length (input variable) >=1
this condition itself says the length of the value entered in input must be greater than one or equal to one

So if you type any number 0 - 9, anything even trailing spaced if you not using the trim() function,

so if I type 0 = length = 1
00 = length = 2
000 = length = 3
123 = length = 3

It is accepting this because it is validating it as true

What's wrong here?
Or you are trying to achieve something else?
If you want to enter a number you can, you can create a pattern using regular exp that will help you validate it.
for numbers you can check : 
You can create your own or you will some on forums

Thanks

UserImage.jpg
Fabiano Silva

Sorry, I thought I put the entire condition, the check is

(Length(Input variable) >=1 and Length(Input variable <9) or

Length(Input variable) >=1 and Length(Input variable >9)

2018-10-29 08-31-03
João Marques
 
MVP
Solution

Hi Fabiano,


I would suggest using a Mask and make use of RegEx (Regular Expression) patterns.

I would use the Input Mask Reactive forge asset, and would use the InputPatternMask


I would use the pattern (^(?!0$))(^(?!1$))(^(?!123$))((\d)+| )

This pattern basically says that it does not allow a 0, nor a 1, nor a 123 and accepts any number of digits or a space.


Kind Regards,
João

UserImage.jpg
Fabiano Silva

In this case, I can let the user enter any sequence, including starting with "0", my only restriction is that if the user enters a number in the field, this sequence must have size 9. I used the expression ^[0-9]{9 }, but it is not accepting if the sequence starts with "0"

2018-10-29 08-31-03
João Marques
 
MVP

Hi Fabiano,


I am getting confused with your requirements for the field.

From what I understand, your field should contain either 9 digits or left empty, right?

In that case, your pattern should be ((\d){9}|^$)

A brief explanation on the patterns:

  • \d indicates a digit
  • {9} indicates it has to be 9-char length
  • | indicates an or
  • ^ indicates the beginning of the string and $ the end. Both together without anything in the middle, means an empty string


Cheers,
joão

UserImage.jpg
Fabiano Silva


Examples of strings that can be 

typed:012346542

687593842" "

cannot accept:

0

235

23475098 = eight digits

2019-02-27 17-48-20
Caldeira81

Hi Fabiano,

You can use Regex expressions of course and validate your form and fields if the values are valid or not or even also use forge components (assets)  

But why do you instead of of validating after inserting values, prevent from the users input those forbidden values? 

check this article about using JS to allow or not the user inserting numbers.

How to create simple validations for your screen text inputs :

https://medium.com/kinetit/how-to-create-simple-validations-for-your-screen-text-inputs-11954031513a

I did not try this on a reactive app but in a web traditional but i guess is about the samme.

Regards,

UserImage.jpg
Fabiano Silva

Unfortunately, here in the project the company does not allow the use of JS


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.