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

masked text box

5 Answers 222 Views
Input
This is a migrated thread and some comments may be shown as answers.
mww
Top achievements
Rank 1
mww asked on 26 Nov 2008, 09:40 AM
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

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 Nov 2008, 10:45 AM
Hi Mark Wheeler,

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

Display Format

Thanks,
Princy.
0
mww
Top achievements
Rank 1
answered on 26 Nov 2008, 10:59 AM
this doesnt achive the desired functionality, I cant enter any spaces.  I need to enter numbers like this


020 123 4567
07902 123 456
0
Daniel
Telerik team
answered on 26 Nov 2008, 11:33 AM
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.
0
mww
Top achievements
Rank 1
answered on 26 Nov 2008, 01:36 PM
that example doesnt work, the value of 'val' in the alphaNumericCheck function is always 'undefined'
0
Daniel
Telerik team
answered on 27 Nov 2008, 07:01 PM
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.
Tags
Input
Asked by
mww
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
mww
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or