This is a migrated thread and some comments may be shown as answers.

Problem with pasting when Multiline and Maxlenght

3 Answers 137 Views
Input
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 02 Jun 2015, 12:50 PM

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

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 05 Jun 2015, 08:15 AM
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
0
Andreas
Top achievements
Rank 1
answered on 05 Jun 2015, 09:32 AM

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

0
Kostadin
Telerik team
answered on 10 Jun 2015, 05:42 AM
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
Tags
Input
Asked by
Andreas
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Andreas
Top achievements
Rank 1
Share this question
or