Restricting Characters in Input



I have an issue where an ampersand (&) is put into a text box by the user, and it returns an error because this is a special character for XML. What are your recommendations for restricting this character or replacing it with & within the string? Can I use LUA to search the input string and replace it? What would be the syntax for that?

Have more questions? Submit a request


  • 0

    I've had luck accomplishing this in lua using the gsub function (string.gsub(myinput,'&','&')):

    Basically you'd probably have to do something like this:


    -- get the value of your input control

    local myinput = thisview:getControl("myinputcontrol"):getValue()

    -- set the value of your input control to a new string with & replaced with &


    And you'll probably want to do this on the submit event in your case, but if you put it on the on change event for the control it will actually make those changes as they type.


    Hope that helps!


Please sign in to leave a comment.
Powered by Zendesk