Text Field - How do I reject names with numbers in them???


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Text Field - How do I reject names with numbers in them???

  1. #1
    Jason Guest

    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

  2. #2
    Soft Solution System Limited Guest

    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> gl 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center