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

Allow only characters

4 Answers 1725 Views
MaskedTextBox
This is a migrated thread and some comments may be shown as answers.
Bilal
Top achievements
Rank 2
Bilal asked on 21 Feb 2015, 12:50 PM
Hi,
I am looking for a way to allow users to enter only characters/spaces for the Name field. How is it possible to tell MaskedTextbox to do so? I tried a sample here:
http://dojo.telerik.com/@bhaidar/itIYI/2

The problem is I have to specify the number of fields. Is there a way to leave that open? User can enter as much characters as he/she wants, however, all are characters.

Best regards
Bilal Haidar

4 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 24 Feb 2015, 01:21 PM
Hello Bilal,

The MaskedTextBox accepts fixed-length input by definition. If you require variable (or unlimited) input length, you will need to use another widget. For example, if you will be supporting IE10+ and other contemporary browsers only, you can use the pattern attribute with a plain <input> element. You can style standard textboxes to look like Kendo UI textboxes with the k-textbox CSS class.

Regards,
Dimo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Bilal
Top achievements
Rank 2
answered on 25 Feb 2015, 08:01 AM
Thanks for the explanation.

I am using the pattern as you suggested:
<input name="firnam-#= uid #" pattern="[a-zA-Z]+" data-pattern-msg="Only characters allowed" required data-required-msg="Required" class="input-width-75 k-textbox" data-bind="value: firstName" />

The above is part of a template. However, only required is working. The pattern is not! I can enter numbers and no warning pops up. Any idea why?

Thanks
0
Dimo
Telerik team
answered on 27 Feb 2015, 05:53 AM
Hello Bilal,

The pattern HTML attribute triggers the built-in browser validation, if the browser supports it. This attribute is not related to Kendo UI in any way does not trigger Kendo UI validation. If you need to use Kendo UI validation, then define a custom rule.

http://docs.telerik.com/kendo-ui/framework/validator/overview#custom-validation-rules

Regards,
Dimo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Bilal
Top achievements
Rank 2
answered on 27 Feb 2015, 06:21 AM
Hi Dimo,
I ended up with a custom validation using a regular expression to test against the value! Thank you.

Best regards
Bilal Haidar
Tags
MaskedTextBox
Asked by
Bilal
Top achievements
Rank 2
Answers by
Dimo
Telerik team
Bilal
Top achievements
Rank 2
Share this question
or