Problem with pasting when Multiline and Maxlenght

4 posts, 0 answers
  1. Andreas
    Andreas avatar
    137 posts
    Member since:
    May 2008

    Posted 02 Jun 2015 Link to this post

    Hi,

    When setting the maxlength and using multiline, you can paste more characters than you can type!

    In your demo:

    http://demos.telerik.com/aspnet-ajax/input/examples/radtextbox/firstlook/defaultcs.aspx

    • Set the maxlength to 10.
    • Paste the following​ in the multiline textbox:

    1
    2
    3
    4
    5

    All of the lines are pasted, but this should not be possible since a new-line should count as 2 chars!

    When trying to write this text with the keyboard it will stop at "4".

    Tried this in both Firefox and IE11.

    Regards
    Andreas

  2. Kostadin
    Admin
    Kostadin avatar
    1713 posts

    Posted 05 Jun 2015 Link to this post

    Hi Andreas,

    Note that by default textarea does not support MaxLenght property and we implement this feature in our controls. Nevertheless I am afraid that this feature might not work correctly in a different browsers and might behaves differently. Generally the purpose of MaxLenght in multi line is to add a value like 3000 or 4000 and in this case the new line will not be a problem. Otherwise if you need a small value you might consider using another control to achieve your requirement or implement a custom logic where the new line will not be taken into an account.

    Regards,
    Kostadin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andreas
    Andreas avatar
    137 posts
    Member since:
    May 2008

    Posted 05 Jun 2015 in reply to Kostadin Link to this post

    Hi,

    Well the real problem for us is that we have a database field that takes 2000 chars, and we set the MaxLength to 2000. When users pastes large content, they will get error since it doesn't fit in the database field, but if users types the text manually it works correctly!

    Regards
    Andreas

  5. Kostadin
    Admin
    Kostadin avatar
    1713 posts

    Posted 10 Jun 2015 Link to this post

    Hello Andreas,

    Could you please let me know whether you have applied a server side validation? Keep in mind that it is a good practice to validate the values before updating the database. Otherwise there is a change a user to disable the scripts on the page and this way to make an injection. For this purpose you can get the enter value and remove the characters which exceeded the max length of the database field. Another approach is to get remove the new lines from the value and update the database this way.

    Regards,
    Kostadin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top