442
Views
5
Comments
Solved
Check Max Length - Input of Type Number
Question
Application Type
Reactive
Service Studio Version
11.53.15 (Build 61263)

Hello everyone,

I'm building a reactive web app and i'm stuck in a number type input. I was asked to add the custom validations:

- Check if the number is exactly 9 characters and display associated message;

- Check if the number is positive and display associated message.

I was able to control the max input length though JavaScript but i'm unable to add the necessary condition to verify if the number is actually of 9 characters. Also, i've checked in Debugging for the value returned by the input and it's 0 (i don't know why).

Here is the JS code:


Here is the value returned through Debugging:

The condition of the IF is the following:

ParentsRegister.NIF = 9


I appreciate your help.

Best regards,

Miguel Figueiredo

2021-08-12 05-19-40
Shubham Janbandhu
Solution

Hi Miguel Figueiredo,

Exactly, you will not able to use Length() for Number input but you can convert Number to Text right. Give it a try, 

1) set onchange event to input, take local variable as"Text" inside handler(screen action), and at onchange, assign "Text = Number var" and use Length() to find the exactly 9 characters

2) And I hope you know the condition for the positive number. i.e Number is >= 0.

Ex-

Result:

 Hope this example helps you.

Best Regards,

Shubham

2024-04-11 10-55-06
Miguel Figueiredo

Hello Shubham,

Thanks for your help, it worked.

I've adapted the logic you sent to be applied in the server side, to send the user the information after the SaveOnClick action. I'll leave the screenshot for you to see:

Many thanks my friend, i've been bustin my head for this.


Best regards,

Miguel Figueiredo


2021-08-12 05-19-40
Shubham Janbandhu

I am so glad that your problem got solved.

Thank you.

Cheers!

2025-10-10 00-19-44
Bruno Rendeiro

Hello Miguel Figueiredo 


Your condition on the if can be like this 


Length(ParentsRegister.NIF ) = 9 


Did you tried this?

And your getting the value 0 on the ParentsRegister.NIF, you are recording the number in that variable well?

2024-04-11 10-55-06
Miguel Figueiredo

Hi Bruno,

Yes, i've tried. But Length applies to Text and my input is of type Number. I can't find a built in function to verify this condition.

What do you mean by recording?

2021-08-12 05-19-40
Shubham Janbandhu
Solution

Hi Miguel Figueiredo,

Exactly, you will not able to use Length() for Number input but you can convert Number to Text right. Give it a try, 

1) set onchange event to input, take local variable as"Text" inside handler(screen action), and at onchange, assign "Text = Number var" and use Length() to find the exactly 9 characters

2) And I hope you know the condition for the positive number. i.e Number is >= 0.

Ex-

Result:

 Hope this example helps you.

Best Regards,

Shubham

2024-04-11 10-55-06
Miguel Figueiredo

Hello Shubham,

Thanks for your help, it worked.

I've adapted the logic you sent to be applied in the server side, to send the user the information after the SaveOnClick action. I'll leave the screenshot for you to see:

Many thanks my friend, i've been bustin my head for this.


Best regards,

Miguel Figueiredo


2021-08-12 05-19-40
Shubham Janbandhu

I am so glad that your problem got solved.

Thank you.

Cheers!

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