Required Digit in Mask

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

    Posted 02 Jul 2008 Link to this post

    I don't see this documented anywhere, so maybe this should be filed under "wishes", but did I miss a way to define a required digit in a mask?

    I'd like to define a mask for, say, zip code that REQUIRES the first 5 digits, with the others being optional.

    If not, consider it a request for the future. :)
  2. Plamen Peshev
    Admin
    Plamen Peshev avatar
    886 posts

    Posted 07 Jul 2008 Link to this post

    Hello Chris,


    You can use CustomValidator control. The following code example demonstrates how to use the ClientValidationFunction property to specify the name of the function that performs client-side validation of the RadMaskedTextBox:

            <div> 
                <script type="text/javascript"
                   function ClientValidate(source, clientside_arguments) 
                   {         
                        var input = $find("<%= RadMaskedTextBox1.ClientID %>"); 
                        var textBoxValue = input.get_textBoxValue();. 
                         
                        if (is first 5 digits) 
                        { 
                            clientside_arguments.IsValid = true
                        } 
                        else  
                        { 
                            clientside_arguments.IsValid = false
                        } 
                   } 
                </script>         
                <telerik:RadMaskedTextBox  
                    ID="RadMaskedTextBox1"  
                    runat="server"  
                    Mask="#####-####"
                </telerik:RadMaskedTextBox> 
                 
                <asp:CustomValidator ClientValidationFunction="ClientValidate" ControlToValidate="RadMaskedTextBox1" ID="CustomValidator1" runat="server" 
                    ErrorMessage="CustomValidator"
                </asp:CustomValidator> 
                 
                <asp:Button ID="Button1" runat="server" Text="Button" /> 
                 
            </div> 




    Greetings,
    Plamen
    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. Brian Azzi
    Brian Azzi avatar
    65 posts
    Member since:
    Mar 2010

    Posted 26 Oct 2011 Link to this post

    I realize this is a very old link... but if anyone finds it, I was able to do this using double zero's in my range... <00..10> force the input of 00, 01, 02, 03, 04, 05, 06, 07... etc.... which is exactly what I wanted here. Just thought I'd share. ;)
Back to Top