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
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:
Best Regards,
Shubham
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.
I am so glad that your problem got solved.
Thank you.
Cheers!
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?
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?