Allow only characters

5 posts, 0 answers
  1. Bilal
    Bilal avatar
    109 posts
    Member since:
    Oct 2014

    Posted 21 Feb 2015 Link to this post

    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
  2. Dimo
    Admin
    Dimo avatar
    8332 posts

    Posted 24 Feb 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Bilal
    Bilal avatar
    109 posts
    Member since:
    Oct 2014

    Posted 25 Feb 2015 in reply to Dimo Link to this post

    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
  5. Dimo
    Admin
    Dimo avatar
    8332 posts

    Posted 26 Feb 2015 Link to this post

    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!
     
  6. Bilal
    Bilal avatar
    109 posts
    Member since:
    Oct 2014

    Posted 27 Feb 2015 in reply to Dimo Link to this post

    Hi Dimo,
    I ended up with a custom validation using a regular expression to test against the value! Thank you.

    Best regards
    Bilal Haidar
Back to Top
Kendo UI is VS 2017 Ready