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

auto trim non-numeric pasted data

1 Answer 347 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Adam King
Top achievements
Rank 1
Adam King asked on 12 May 2017, 09:27 PM

How can I let users paste '123456  ' into my numeric textbox and have it auto-strip the spaces? The spaces are usually at the end but are possibly at the beginning too.

Currently unless I copy/paste all digits nothing gets pasted. I can see it trying to paste but then it automatically disappears.

@(Html.Kendo().NumericTextBoxFor(model => model.DocumentId)
.Spinners(false).Decimals(0).Format("#")

)

Perhaps there's a property to help me do this or an event where I can reliably get the pasted value, strip all but the digits and replace the text before any validation occurs.

 

 

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 16 May 2017, 03:11 PM
Hi Adam,

The behavior you describe would require custom logic. You can handle the paste event of the input element and access the data stored in the clipboard. 

If you would like additional information on accessing the clipboard you would find the stackoverflow thread below interesting.


For your convenience I assembled a small dojo example that outlines the approach. Check it out below:



Regards,
Viktor Tachev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
NumericTextBox
Asked by
Adam King
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or