masked text box

6 posts, 0 answers
  1. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 26 Nov 2008 Link to this post

    I want users to be able to type a telephone number into a masked text box.  This could be a mobile or a landline, so the format can be slightly different.  How can I set the mask so that only numbers 0-9 can be entered as well as a space  but the format isnt really important

    ie 

    020 123 456
    07968 111 333
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 26 Nov 2008 Link to this post

    Hi Mark Wheeler,

    Please check the below link of online demo that demonstrats the desired functionality.

    Display Format

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 26 Nov 2008 Link to this post

    this doesnt achive the desired functionality, I cant enter any spaces.  I need to enter numbers like this


    020 123 4567
    07902 123 456
  5. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 26 Nov 2008 Link to this post

    Hello Mark,

    It's possible to use regular expressions with regular RadTextBox control as shown in the following forum thread:
    RadMaskedTextBox client validation

    Regards,
    Daniel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 26 Nov 2008 Link to this post

    that example doesnt work, the value of 'val' in the alphaNumericCheck function is always 'undefined'
  7. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 27 Nov 2008 Link to this post

    Hello Mark,

    I modified the code for RadControls for ASP.NET AJAX:
    <script language="javascript" type="text/javascript"
        function RadTextBox1_KeyPress(sender, args) 
        { 
            if (alphaNumericCheck(args.get_keyCharacter())) 
                return true
            else 
            { 
                alert("Wrong symbol"); 
                return false
            } 
        } 
     
        function alphaNumericCheck(val) 
        { 
            var regex = /^[0-9A-Za-z_-]+$/; 
            if (regex.test(val)) 
                return true
            else 
                return false
        }  
    </script> 

    Regards,
    Daniel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017