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

MaskedTextBox allow decimals at any position with maxlength

2 Answers 834 Views
MaskedTextBox
This is a migrated thread and some comments may be shown as answers.
Ratno
Top achievements
Rank 1
Ratno asked on 17 Mar 2017, 07:51 AM

Hi,

I have a requirement where user can enter numbers with decimals with max length of 10 and the decimal point can occur anywhere within the input. Sample input can be like 1223.4588, 123456.78, 012.45, 678 etc

Can i use the rules option of the maskedtextbox to achieve this. I guess the only option would be to use a regex pattern but it doesn't seem to work. We tried below and also k-mask="'00000.0000'" but none seem to work

$("#id").kendoMaskedTextBox({
   mask: "{{^(?!0\d|\.|.*?\..*?\.)(?=(?:\.?\d){1,10}$)(.*)$}}"
}); 

For requirement above will the numerictextbox serve the purpose ?

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 20 Mar 2017, 02:24 PM
Hello ,

Currently, the desired result is not supported out of the box from both widgets.

For the NumericTextBox, I can suggest the following example demonstrating how to restrict the number of entered characters. Additional custom logic can be added, to check if a decimal point is present to changed the number of allowed characters plus one. Please have in mind that this will still not make the same result:

http://jsfiddle.net/krustev/jZVas/

https://www.w3schools.com/tags/att_input_maxlength.asp

I can suggest submitting a feature request, to be able to set maxLenght on the widget which will consider the decimal part as well. Then based on its popularity we may implement it in a future release:

http://kendoui-feedback.telerik.com/forums/127393-kendo-ui-feedback/category/170304-numerictextbox

Regards,
Stefan
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.
0
Ratno
Top achievements
Rank 1
answered on 23 Mar 2017, 09:12 AM

Thanks Stefan. Apparently the max length will not solve our purpose but we will consider submitting the feature request in the forums.

To solve our issue we reverted back to using a normal HTML input element with a custom attribute and used a custom angular directive to check for the regex and the length together.

Tags
MaskedTextBox
Asked by
Ratno
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Ratno
Top achievements
Rank 1
Share this question
or