Input field should accept only digits while pasting from clipboard.
Application Type
Mobile, Reactive

I've an input box which should only accept digits while doing copy paste on to it.

Hi @Ajay Kiran P,

Have you tried using an input mask component?
You can have a look at this one for example: https://www.outsystems.com/forge/component-overview/7838/inputmask-react

This component allows you to specify what type of characters can be inserted in the input, as well as the length and text format.

Regards,

Manuel

Hi @Manuel Rodrigues,

Does the input field allows the restricted characters when copying and pasting?
If it works, can you please share your oml file if possible?

Regards,
Aj

Hi @Ajay Kiran P,

Please go through this discussion:  https://www.outsystems.com/forums/discussion/22900/how-to-allow-user-to-enter-only-numbers-in-text-box/  

or else you can use javascript code :

function isNumber(evt) {
    evt = (evt) ? evt : window.event;
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        return false;
    }
    return true;
}

Regards
Neha

  

Hi Neha,

This allows other characters when you copy and paste some context inside the input field.
Share you oml file if it works fine with you when copying some content and pasting it inside an input field.
Thanks for the response.

Regards,
Aj

Hi Ajay,

You can simply assign an integer variable to the input widget, it won't allow you to either enter or copy-paste text, It will only allow numbers. You can refer to screenshot.

Regards

Neha 

Capture.PNG

Hi Neha,

How can it be achieved by using text type as input variable? I'd to use text variable as input.

Regards,
Aj

Hi @Ajay Kiran P ,

Please refer this oml. In this It won't be allowed you to enter any Characters , copy & paste any characters from keyboard.

Hope this will help you.

Thanks,

Safiya Shaikh.

inputfieldValidation.oml

Hi @Safiya Shaikh ,

This works like charm, but the input field should accept numbers when copying and pasting.

Regards,
Aj

Hi @Safiya Shaikh ,

This oml accepts everything from clipboard all the special characters, alphabets and numbers.

Regards,

Aj

Hi Ajay,

As Manuel Rodrigues  suggested you can use  https://www.outsystems.com/forge/component-overview/7838/inputmask-react  component. This component will restrict the characters while pasting the text.

I have attached the demo URL provided  by the above mentioned component.

https://ellakkiya-selvadurai23.outsystemscloud.com/InputMaskReactiveSample/Example?_ts=637593588906491029

If this component doesn't suits your requirement then, there are many components  available in forge

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

https://www.outsystems.com/forge/component-overview/7819/input-mask-reactive


Regards,

Ellakkiya.S

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