Hi Kavya,
You can try the InputBoxOctober widget (it allows you to specify a mask for a string input field). I have tested it on mobile along with an attribute whose maximum length is set and I've found that it works nicely: https://appstore.home.mendix.com/link/app/4625/Mendix/InputBoxOctober
Thanks,
Conner
I tested this on an andriod phon (S7) using the Mendix developer app.
With added a custom restriction on the widget, it allows me to enter more then the restricted number of characters. When I step out of the widget it cuts off to the restricted Nr of characters.
To me this feels like a bug or at least undesired behavior. I suggest you file a ticket @ Mendix support