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

Required Digit in Mask

2 Answers 123 Views
Input
This is a migrated thread and some comments may be shown as answers.
Chris T.
Top achievements
Rank 1
Chris T. asked on 02 Jul 2008, 01:35 PM
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 Answers, 1 is accepted

Sort by
0
Missing User
answered on 07 Jul 2008, 11:40 AM
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
0
Brian Azzi
Top achievements
Rank 2
answered on 26 Oct 2011, 08:28 PM
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. ;)
Tags
Input
Asked by
Chris T.
Top achievements
Rank 1
Answers by
Missing User
Brian Azzi
Top achievements
Rank 2
Share this question
or