RadMaskedTextBox validation

6 posts, 0 answers
  1. EkoEvolution
    EkoEvolution avatar
    6 posts
    Member since:
    Oct 2006

    Posted 09 Oct 2007 Link to this post

    I am trying to use a RegularExpressionValidator on a RadMaskedTextBox that is collecting a US Zip Code. I am using the following properties:

    Mask="#####-#####"
    DisplayMask="#########"
    DisplayPromptChar=""
    SelectionOnFocus="CaretToBeginning"
    ResetCaretOnFocus="true"

    My RegularExpression is ^((\d{5}(-|\s)\d{4})|(\d{5})$

    This fails for 32608 but works for 32608-0000 when using RadMaskedTextBox

    The regular expression works when I do not use a RadMaskedTextBox and fails when I do. I read that the RadInput validates against a stripped version of the Text which should validate both 32608 and 32608-0000.
  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 12 Oct 2007 Link to this post

    Hello,

    Indeed, with the regular expression that you have used, only expressions like 32608-0000  will be accepted. Another alternative would be to use client side script, to add 0's when the user only enters the first five digits. This can be done in the onBlur event on the client. Yet another approach is to change the regular expression, to allow 0-4, or 5 characters in the second sequence:

    .aspx
    <asp:RegularExpressionValidator runat="server" ID="RegularExpressionValidator1" 
     ValidationExpression="^((\d{5}(-|\s)\d{0,4})|(\d{5}))$"   
     ControlToValidate="RadMaskedTextBox1" 
     ErrorMessage="Incorrect Format!!!">  
    </asp:RegularExpressionValidator> 

    I hope this information helps.

    Best wishes,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. John
    John avatar
    416 posts
    Member since:
    Oct 2006

    Posted 24 Oct 2008 Link to this post

    Hi,

    You can review this blog post

    Regards...
    <John:Peel />
  5. Murugavel B
    Murugavel B avatar
    10 posts
    Member since:
    May 2010

    Posted 29 May 2010 Link to this post

    Is it fixed?
  6. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 03 Jun 2010 Link to this post

    Hello Murugavel B,

    Presently, the behavior is the same as explained initially. No modifications have been introduced to this functionality. Nevertheless, you can use the regular expression option, or the client script approach to handle the setup.

    Kind regards,
    Yavor
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
  7. Atlas
    Atlas avatar
    97 posts
    Member since:
    Jun 2009

    Posted 31 Aug 2010 Link to this post

    The validation expression that Telerik didn't work for me, but this did:
    <asp:RegularExpressionValidator ValidationExpression="^((\d{5}-_{0,4})|(|(\d{5}-\d{4})))$" ID="RegularExpressionValidator6"
        ValidationGroup="vgBrokerApplication" runat="server" Display="None" ErrorMessage=" Invalid zip code "
        ControlToValidate="rmtbZip" />
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017