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

Get Mask property of RadMaskedTextBox in Javascript

2 Answers 160 Views
Input
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 30 Jul 2009, 12:11 AM
Is this possible?  I've been trying to a few hours to figure it out, but can't find a way.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 30 Jul 2009, 06:30 AM
Hi Mike,

You can get the Mask value of RadMaskedTextBox from client-side using _initialMasks method which returns an array of mask elements.

JavaScript:
 
<script type="text/javascript"
function mask() 
    var Input = $find("<%= RadMaskedTextBox1.ClientID %>"); 
    var mask = Input._initialMasks; // returns array of mask elements 
</script> 
You can also checkout the following forums link which discusses how to set the Mask property from client side.
Setting Mask with Javascript

-Shinu.
0
John
Top achievements
Rank 1
answered on 30 Jul 2009, 01:53 PM
Great, that was the answer.  In case anybody needs this, I created a javascript function that is a more user-friendly implementation of MaxLength in a RadMaskedTextBox.  I did not like how extra characters showed for a second and then disappeared.



function RadMaskedTextBoxKeyPress(sender, args) {  
     var maskLength = sender._initialMasks.length;  
     var valueLength = sender.get_valueWithLiterals().length;  
     if (valueLength == maskLength) {  
         args.set_cancel(true);  
     }  

Tags
Input
Asked by
John
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
John
Top achievements
Rank 1
Share this question
or