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

RadMaskedTextBox

3 Answers 141 Views
Input
This is a migrated thread and some comments may be shown as answers.
Anil
Top achievements
Rank 1
Anil asked on 30 Jun 2009, 12:00 PM
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

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Jun 2009, 02:48 PM
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.
0
Anil
Top achievements
Rank 1
answered on 01 Jul 2009, 02:19 PM
I have  

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

0
Phil DeVeau
Top achievements
Rank 1
answered on 28 Sep 2009, 08:22 PM
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.
Tags
Input
Asked by
Anil
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Anil
Top achievements
Rank 1
Phil DeVeau
Top achievements
Rank 1
Share this question
or