Request for Assistance: Detecting Copy-Paste Inputs and Limiting Text Input in ODK Forms

Dear ODK Community Team,

I hope this message finds you well.

I am currently working on a form where I want to detect if a user has copy-pasted text into a text input field. Since ODK doesn't natively detect copy-paste actions, I have implemented a workaround by tracking the time it takes a user to fill the input. If the input is completed in just a few seconds, it likely indicates that the user pasted the content instead of typing it manually. In such cases, I display a warning message to inform the user that pasted content is not allowed.

However, I am facing some issues with this logic and would kindly ask for your assistance in finding a better or more reliable solution to detect copy-paste behavior in ODK forms, if possible.

In addition, I would like to apply the following constraints to the text input field:

Limit the input to 100 characters maximum.

Only allow text written in Dari or Pashto (i.e., restrict input to certain Unicode character ranges).

Prevent any other characters such as English letters, numbers, or special symbols from being entered.

If there is a way to achieve these constraints using regex, constraint expressions, or custom logic in XLSForm/ODK, I would greatly appreciate your guidance or any examples you can provide.

Text Duration.xlsx (16.4 KB)

This one is straightforward as you can set a constraint using string-length <= 100 - docs

This one should be doable with a regex constraint that only allows the unicode range(s) you want (or disallows the range(s) outside it). I don't know the exact ranges you need but they should be here. Basic examples;
regex(.,'^[\u0600-\u06FF]+$') should allow characters in the arabic range
regex(.,'^[^\u0000-\u007F]+$') should disallow characters in the basic latin range

1 Like

what about this issue?

please see this xlsform

apologies, I didn't check your form as the post read as if it was asking how to set constraints on string length and character input, I didn't realise you were only asking for assistance on how to prevent pasting text (in conjunction with string / character limits). You might be able to simplify your regex with unicode ranges though.

1 Like

? please check this one

Thanks, I want to prevent from the copy past.