113
Views
14
Comments
Restrict special characters on copy paste
Question
Application Type
Reactive
Service Studio Version
11.54.41 (Build 63060)

Hello all,

How to restrict special characters when copy/paste into text, numbers or alphanumeric input fields in application onready!

Thanks in advance.

2024-07-12 05-57-50
Gourav Shrivastava
Champion

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

Test.oml
UserImage.jpg
Sonali Murugan

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!

2024-07-12 05-57-50
Gourav Shrivastava
Champion

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 

Regards Gourav Shrivastava


Test.oml
UserImage.jpg
Sonali Murugan

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. 

2024-07-12 05-57-50
Gourav Shrivastava
Champion

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.

Thanks 

Regards Gourav Shrivastava

UserImage.jpg
Sonali Murugan

Hi,

The current implementation restricting but returning empty string when I'm passing those values to the next screen! attached oml for reference 

Thanks

RestrictSpecialChars.oml
2025-04-17 05-42-16
Ajit Kurane

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.


UserImage.jpg
Sonali Murugan

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.

Thanks.

2025-04-17 05-42-16
Ajit Kurane

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,

Ajit Kurane.

UpdatedByAjitKurane.oml
UserImage.jpg
Sonali Murugan

Hi Ajit, 

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.

Thanks

2024-12-10 04-40-04
Gitansh Anand

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.

Thanks
Gitansh Anand

UserImage.jpg
Sonali Murugan

Hi Gitansh,

Thanks for your response, I'm looking for a common script that should restrict special chars.

Thanks

2023-11-20 06-53-17
Neha Rathore

Hi Sonali,

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 helps

Thanks


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