How to set max length for number datatype input field?
Question

I wanted to limit the number of data filled inside an input field. But doesn't work by adding attributes to it.

maxlen.PNG

Hello!

So you need to do send the value to action and use the function length to see the length of your input. When the input passes the limit, you change for example a Boolean variable indicating that it was passed the limit and also you put the widget valid of input as false and insert the validation message also. That Boolean value you can use to show a message. If (isOffLimit ,showMessage,"")

I attached a possible solution covering validating the form and check the max length

´Regards,


Márcio Carvalho

Exemplo.oap

Champion

Hi Ajay Kiran, 

Please Check- Discussion


Hope this help,

Thanks

I saw this discussion, but you can do it without javascript. Javascript is good, but you will not use tape to fix everything :) I think that discussion was almost 2 years ago when there was not reactive.

Regards,

Márcio Carvalho

Hi Marcio Carvalho,

Thanks for the response. Sharing an .oml file would help me understand much better. I'm a beginner. So, could you help me with this?

Regards,

Aj


i attached the file :) I am trying a best solution for your case.

I added a new solution in my first reply, you can check it. You can try the 2 options that Ajay and I gave to you. the solution from another post or the OutSystems logic way.

If you need help is just saying.

Regards, Márcio Carvalho

Hi Marcio Carvalho,

I'll explain you my requirement. I've 4 input fields in a form. If I fill the first field it should redirect me to next field and the max length of each field is 1. The length shouldn't exceed even if I try to type coming back to the first field and the input field shouldn't be disabled. How do I make this? Can you suggest me some ideas or posting an .oml file would be more helpful.

Regards,

Aj


I am trying to find it, but you have to do something like this using javascript.

https://jsfiddle.net/4m5fg/5/

Hi,

we can use the input widget max length property for set limit of number input field


Hi Shradha Rawlani,

Thank You very much for your response. But I'm working on reactive :/

Champion

Hi Ajay kiran,

Sorry for late reply.

Max. Length attribute is  only available for only Input Type - Text. 

For example you can see in below image, It prevent user filling more than 2 character. 


Input Type - Number , there is no such property that limit filling characters. But you can achieve it by using javascript.

You can find that javascript at onkeydown event handler.

I uploaded  My OML. Please Check. 


Hope this help,

Thanks and regards,

Rahul


InputMaxLength.oml

https://marcio-carvalho4.outsystemscloud.com/Exemplo/StudentDetail  Go to the input age and try.

I did it without using javascript. What I am trying to say is, neither every solution to a problem needs to have a javascript solution, you will need to take really care of javascript because you can get into trouble in the meanwhile.

If you have functions, actions on OutSystems, you must use them To not invent the wheel, you understand??

I leave here my file with another solution the same one I post it here this morning. But this time I just used the onkeypressed and simple action to solve "my" problem.


Regards,

Márcio C.

Exemplo.oap

One week passed and today I needed to go to this thread to see a solution :D

Regards,

Márcio C. 

Hi @Ajay Kiran P 

Check this component: https://www.outsystems.com/forge/component-overview/2258/input-masks-library

I build an example of it. Check it here if it is what you want: https://galmeida.outsystemscloud.com/Masktest/Home?_ts=637545385340470351

In this case, only allows 1 char and must be an integer.

You can also check the code in the oml attached.

Regards

Gonçalo Almeida

Masktest.oml

Hi Ajay,

As per the below link, maxlength property of input box will not work in google chrome. Please refer this.

https://stackoverflow.com/questions/18510845/maxlength-ignored-for-input-type-number-in-chrome

So, if there would not be any specific requirement to not to use javascript, please go with that option.

Thanks & Kind Regards,

Sachin

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