-
Text Field - How do I reject names with numbers in them???
I am looking to filter a name field to verify that no numbers have been placed
in the text field. Simple syntax on how to check the string for numbers???
Thanks,
Jason
-
Re: Text Field - How do I reject names with numbers in them???
The following text is extracted from the Java Manual, you can filter what
you like:
Customized fields can easily be created by extending the model and changing
the default model provided. For example, the following piece of code will
create a field that holds only upper case characters. It will work even if
text is pasted into from the clipboard or it is altered via programmatic
changes.
public class UpperCaseField extends JTextField {
public UpperCaseField(int cols) {
super(cols);
}
protected Document createDefaultModel() {
return new UpperCaseDocument();
}
static class UpperCaseDocument extends PlainDocument {
public void insertString(int offs, String str, AttributeSet a)
throws BadLocationException {
if (str == null) {
return;
}
char[] upper = str.toCharArray();
for (int i = 0; i < upper.length; i++) {
upper[i] = Character.toUpperCase(upper[i]);
}
super.insertString(offs, new String(upper), a);
}
}
}
"Jason" <java.@127.0.0.1> ¼¶¼g©ó¶l¥ó news:3cbc80b3$1@10.1.10.29...
>
> I am looking to filter a name field to verify that no numbers have been
placed
> in the text field. Simple syntax on how to check the string for
numbers???
>
> Thanks,
> Jason
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks