Hello all,
How to restrict special characters when copy/paste into text, numbers or alphanumeric input fields in application onready!
Thanks in advance.
Hi,
Use can refer these links:
https://www.outsystems.com/forums/discussion/72085/how-to-prevent-paste-of-letters-in-input-text/
https://www.outsystems.com/forums/discussion/85229/restrict-user-to-enter-number-and-special-characetrs-but-only-letters/
Hope this helps!
Hello Sonali Murugan,
You can easily archive this with JavaScript, without using any component.
Simply you have to add JavaScript code on "onReady" event of the page and pass the input ID to the javascript code i have attached the sample application you can refer to this.
Thanks
Regards Gourav Shrivastava
Thanks much for the immediate response everyone.
@Gourav Shrivastava I have tried with class name and its working fine but when I'm passing those copy/pasted values to the next screen, Its returning empty string!
Hello Sonali Murugan
Please confirm if you have one input box or multiple if only one you can select by it's id if multiple so you can select by class for this you have to do this same code in javascript forEach loop . and also do this code on ready event of the screen
I have attached the sample application you can refer to this.
Thanks for your response Gourav,
This copy/paste restriction needs to be implemented throughout the application in multiple inputs that may have only text or only number. so that's why I will be using a class to call this js on ready.
Please refer above OML file which will be helpful for you i have done this with the class selector, also mark it as solved if this works.
The current implementation restricting but returning empty string when I'm passing those values to the next screen! attached oml for reference
I have checked above OML and its working fine. Its passing values to the next screen.
You can check here,
personal-xyog61l7.outsystemscloud.com/RestrictSpecialChars/TextModifyJS?_ts=638407834833263029
Then what issues are you facing ?
Thanks.
Ajit Kurane.
Hi Ajit,
Thanks for your response. Without typing any chars in input field, just copy/paste some content which includes special chars and navigate to next screen the text won't appear.
Hi Sonali,
I have updated your OML as per your requirment.
Please check and let us know.
Demo link : https://personal-xyog61l7.outsystemscloud.com/RestrictSpecialChars/TextModifyJS?_ts=638408460098067659
Thanks,
Thanks for your time, but I need some global level script that should restrict special chars instead of calling the same script again and again in all the screens of the application.
shared OML is not working on mobile device when I copy/paste for the first time but its working on desktop.
Hi @Sonali Murugan, I have read your previous comment, and I realize that you are looking for a solution that you can apply using OnApplicationReady, but if you can't find a solution like that, you can use my component Restrict Characters, Here is the demo for the component; it works for both web and mobile.
Please note that it works with input type text only, and you will have to apply this to all inputs separately.
ThanksGitansh Anand
Hi Gitansh,
Thanks for your response, I'm looking for a common script that should restrict special chars.
If Javascript is not working, you go with the server action also."On change" of the field you can check that it has special chars or not?Just try a different approach.Hope this helpsThanks