MaskedTextBoxFor not requiring 0 be filled in

4 posts, 0 answers
  1. Chris T.
    Chris T. avatar
    26 posts
    Member since:
    Apr 2008

    Posted 15 Jun 2016 Link to this post

    We have what SHOULD be a simple SSN entry field:

    @Html.Kendo().MaskedTextBoxFor(model => model.SSN).Mask("000-00-0000").UnmaskOnPost(true).HtmlAttributes(new { @class = "form-control", style = "width:125px" })

    The problem we're having is that if we leave some digits not filled in (i.e. - "555-33-2"), no error is thrown.  Aren't the 0s supposed to be required digits?

    Also, we have a regex attribute on the field in the model, for validations when NOT using the edit form (seeds, etc.).  We're planning to disable it by adding the Html attribute @data_val = "false".  Will that prevent the maskedtextbox from doing its work?

  2. Marshall Long
    Marshall Long avatar
    5 posts
    Member since:
    Jun 2008

    Posted 15 Jun 2016 in reply to Chris T. Link to this post

    Never mind - we found another unrelated error that was causing problems with the page.  Question withdrawn!
  3. Marshall Long
    Marshall Long avatar
    5 posts
    Member since:
    Jun 2008

    Posted 16 Jun 2016 in reply to Marshall Long Link to this post

    On further review, this is still an issue.  When using the 0 to force a digit, why doesn't Telerik throw a client side error?
  4. Georgi Krustev
    Georgi Krustev avatar
    3725 posts

    Posted 17 Jun 2016 Link to this post

    Hello Marshall Long,

    The MaskedTextBox does not have a build-in validation. Any server/client validation should be done separately, like you are doing with the model data annotation attributes.

    If the server/client validation works with a regular Input element, then it will work with the MaskedTextBox.

    Georgi Krustev
    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
Back to Top