Working with TextField Masks
Issue: 8.5 (July/August 2010)
Author: Marc Zeedar editor-at-rbdeveloper.com
Article Description: No description available.
Article Length (in bytes): 11,875
Starting Page Number: 53
RBD Number: 8508
8508.zip Updated: Monday, July 5, 2010 at 4:47 PM
Related Link(s): None
Known Limitations: None
Excerpt of article text...
An often overlooked but extremely powerful feature of REALbasic's TextField control is its mask property. The mask allow you to specify, in advance, what types of data the field can handle. It's great for forcing data to be well-formatted, such as telephone numbers and Zip codes that have a specific format (though you should be aware that different countries often have different formatting). However, masking is so powerful it can be intimidating if you haven't used it, so today we're going to explore the feature in detail.
In principle, masking is simple. You just build a string of placeholder characters and stick it in a textfield's mask property. You're done. In practice, those placeholders can be tricky business and you may still need to check for errors and do some post-entry data massaging.
In the Old Days
Before the mask property was added to REALbasic, getting data entered into a specific format was difficult. You either allowed the user to enter whatever they wanted and then did analysis on the result, editing the data programmatically to force it into the right format, or you had to create your own subclass of a textfield that wouldn't allow certain characters to be entered (i.e. non-numbers in a number-only textfield). (For an example of this, see the "RestrictedField" sidebar.)
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.