Click here to Skip to main content
Licence CPOL
First Posted 1 Apr 2009
Views 35,598
Downloads 2,028
Bookmarked 14 times

Mask TextBox ASP.NET Control

By | 1 Apr 2009 | Article
An ASP.NET textbox to input bank account or credit card numbers or other kinds of formatted text
maskTextBoxTest_net3 - Click to enlarge image

Introduction

This ASP.NET control can be used to input bank account or credit card numbers or other kinds of formatted text.

Background

We needed a way to easily input many bank account numbers in the same page, a quick "paste'n go" approach but also with full format and validation support. The page should also load as fast as possible so the control instances are initialized only when they got the focus and the HTML is not bloated with JavaScript snippets.

Many thanks to Diego Perini (dperini@nwbox.com) who helped me with his samples to get right some caret JavaScript.

Using the Code

If you look in default.aspx, the page that uses the control, pay attention to the following global variable...

<script type="text/javascript">var mtb;</script>		

... that is shared by the control instances and it gets initialized every time one receives the focus.

Points of Interest

Hopefully I will upload an Ajax version and a Java version soon.

I hope this helps!

History

  • 2nd April, 2009: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

radumi

Software Developer

New Zealand New Zealand

Member

Software Developer

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 5 PinmemberSwelborn16:46 1 Apr '11  
GeneralMy vote of 4 Pinmembergstolarov3:47 2 Apr '09  
GeneralRe: My vote of 4 Pinmemberradumi1:26 7 Apr '09  
GeneralMy vote of 1 PinmemberPablo Robert1:20 2 Apr '09  
GeneralRe: My vote of 1 Pinmemberradumi1:24 7 Apr '09  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 2 Apr 2009
Article Copyright 2009 by radumi
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid