Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By pbrockway2

Thread: data type validation

  1. #1
    cagipple is offline Member
    Join Date
    Mar 2011
    Rep Power

    Default data type validation

    Is there a way to restrict the user to enter a specific type of data?

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power

    Default Re: data type validation

    Not without special hardware which is not common on most PCs, and illegal in many jurisdictions.

    A better approach is to not accept the bad data they do enter. For example you might ask for a telephone number and when they have entered it check to see if it conforms to your expectations.

    Many would argue better (and possibly what you were getting at) is to use a GUI component like JFormattedTextField which restricts the value of user entered strings. (It is described in Oracle's Tutorial at the page How to Use Formatted Text Fields). Another approach - which could be used with any text component - is to set a document filter. (Its use is also described in the Tutorial: here.)
    Eranga likes this.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Colombo, Sri Lanka
    Blog Entries
    Rep Power

    Default Re: data type validation

    So basically there is no specific way to do this. Depends on the controls you are using and the design, we can take different approaches. However, if we consider web applications we are more towards to do the validations on client-side and try to avoid overheads on servers. When comes to the desktop application anyway life is more easy.

Similar Threads

  1. Matrix Data Type
    By fraB3422 in forum New To Java
    Replies: 7
    Last Post: 02-27-2011, 02:08 AM
  2. Replies: 4
    Last Post: 01-29-2011, 11:18 PM
  3. which type is a good validation method in struts2
    By javastuden in forum Java Servlet
    Replies: 2
    Last Post: 07-13-2010, 01:25 PM
  4. how to set NVarchar data type
    By edi.gotieb in forum JDBC
    Replies: 9
    Last Post: 05-19-2010, 01:13 PM
  5. Replies: 0
    Last Post: 09-01-2008, 11:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts