RadMaskedTextBox

4 posts, 0 answers
  1. Anil
    Anil avatar
    26 posts
    Member since:
    Jun 2008

    Posted 30 Jun 2009 Link to this post

    Good morning. I have a radMaskedTextBox in my .aspx page. And I am using javascript to populate it. The javascript is fine, it populates the radcontrol with a 10-digit phone number. The control also has a requiredfield validator. When I try to postback the requiredfield validator fails. Please tell me why it fails as I see the phone number in correct format in the control when javascript populates it. But if I type in the same number in the radmaskedtextbox  it passes without any error.
    Thanks
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 30 Jun 2009 Link to this post

    Hi Anil,

    I tried RadMaskedTextBox with RequiredFieldValidator and I found it is working fine in my end even when setting the value from client side. See the code that I tried.

    ASPX:
     
    <telerik:RadMaskedTextBox ID="RadMaskedTextBox1" runat="server" DisplayMask="##########" Mask="##########">  
    </telerik:RadMaskedTextBox> 
     
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="RadMaskedTextBox1" 
        ErrorMessage="RequiredFieldValidator">  
    </asp:RequiredFieldValidator> 
     
    <input id="Button1" type="button" value="button" onclick="setValue();" /> 

    JavaScript:
     
    <script type="text/javascript">  
    function setValue()  
    {  
        var dateInput = $find("<%= RadMaskedTextBox1.ClientID %>");  
        dateInput.set_value('1234567890');      
    }  
    </script> 
    Could you paste the code that you tried if it is different from that I tried?

    Thanks,
    Princy.
  3. Anil
    Anil avatar
    26 posts
    Member since:
    Jun 2008

    Posted 01 Jul 2009 Link to this post

    I have  

    Mask="(###)###-####"
    in my application.. Let me know if it works.
    Thanks.
    Anil

  4. Phil DeVeau
    Phil DeVeau avatar
    19 posts
    Member since:
    May 2009

    Posted 28 Sep 2009 Link to this post

    I had the same problem with phone numbers.  I decided to use a custom validator instead.  I have two RadMaskedTextBoxes one works fine with a RequiredFieldValidator and a RangeValidator.  The other one (also a phone number with the same mask) failed to validate with pre-built validators.  I ended up going with a custom validator.
Back to Top