Preventing the user from copying and pasting from one text field to another.

Hi All.

How can we prevent a user from copying data from a text field and pasting it to diffrent field?

Thanks.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hello,

    You can perform restriction for paste with the help of below implementation.

    Solution is

    - Take a text field.

    -Keep number of chars user can enter.

    -refresh onkeypress

    -check the length of the entered data into text field.

    -if the length is more then the limit then that must be entered using paste.

    -highlight using validation.

    load(
    local!maxCharInput: 2,
    local!value,
    local!oldValue,

    {

    a!textField(
    label: "E-Mail ",
    value: local!oldValue,
    refreshAfter: "KEYPRESS",
    saveInto: {
    local!value,
    if(
    len(
    local!value
    ) - len(
    local!oldValue
    ) > local!maxCharInput,
    {},
    a!save(
    local!oldValue,
    local!value
    )
    )
    },
    validations: {
    if(
    len(
    local!value
    ) - len(
    local!oldValue
    ) > local!maxCharInput,
    "Copy Restricted!!!",
    {}
    )
    }
    )
    }
    )

Reply
  • 0
    Certified Lead Developer

    Hello,

    You can perform restriction for paste with the help of below implementation.

    Solution is

    - Take a text field.

    -Keep number of chars user can enter.

    -refresh onkeypress

    -check the length of the entered data into text field.

    -if the length is more then the limit then that must be entered using paste.

    -highlight using validation.

    load(
    local!maxCharInput: 2,
    local!value,
    local!oldValue,

    {

    a!textField(
    label: "E-Mail ",
    value: local!oldValue,
    refreshAfter: "KEYPRESS",
    saveInto: {
    local!value,
    if(
    len(
    local!value
    ) - len(
    local!oldValue
    ) > local!maxCharInput,
    {},
    a!save(
    local!oldValue,
    local!value
    )
    )
    },
    validations: {
    if(
    len(
    local!value
    ) - len(
    local!oldValue
    ) > local!maxCharInput,
    "Copy Restricted!!!",
    {}
    )
    }
    )
    }
    )

Children
No Data