Get Mask property of RadMaskedTextBox in Javascript

3 posts, 1 answers
  1. John
    John avatar
    16 posts
    Member since:
    Jun 2009

    Posted 29 Jul 2009 Link to this post

    Is this possible?  I've been trying to a few hours to figure it out, but can't find a way.
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Jul 2009 Link to this post

    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.
  3. John
    John avatar
    16 posts
    Member since:
    Jun 2009

    Posted 30 Jul 2009 Link to this post

    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.



    1 function RadMaskedTextBoxKeyPress(sender, args) {  
    2      var maskLength = sender._initialMasks.length;  
    3      var valueLength = sender.get_valueWithLiterals().length;  
    4      if (valueLength == maskLength) {  
    5          args.set_cancel(true);  
    6      }  
    7

Back to Top