Validation Methods


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Validation Methods

  1. #1
    Join Date
    Apr 2006
    Posts
    7

    Validation Methods

    hi,

    i need some help in implementing validation to my program;

    the program prompts the user to enter the details and error message is displayed if a wrong input is entered. The user is then prompted to enter the correct information again. I just need some help with 3 validation methods;

    //able to enter only alphabets and / only
    System.out.print("Enter user name: " );
    user.name = input.readLine();

    While{}

    //must be ONLY 'A' or 'B'
    System.out.print("Enter user prefix (A/B): ");
    String prf = input.readLine();
    user.prefix= prf.charAt(0);

    While{}

    //able to enter only alpha-numeric
    System.out.print("Enter user address: ");
    user.address = input.readLine();

    While{}

    Really appreciate of someone could help me with the conditions for this validation process..

    Thanks!!
    Last edited by Jess_00; 04-09-2006 at 02:48 PM.

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    What attribute are you testing for in each of your while loops - what is being "A or B", or "alphabetic", or "alphanumeric"? How do you test for that/those value(s)? Are there existing methods which will perform that testing for you? Do you need to write your own?

  3. #3
    Join Date
    Apr 2006
    Posts
    7
    hi,

    thanks for the reply. i have highlighted the conditions in RED.
    "A" or "B" are the ONLY two inputs which should be accepted by the program. another other alphabets or numerics entered will prompt an error message and the user will prompted to re-enter the correct value again.

    There are no other existing testing methods and these are the only validation methods to be used for this program.

    thanks.

  4. #4
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    I was trying to prompt your research into the methods available to you for your use in crafting the tests you need. Primarily, I was prompting you to search the J2SE API methods which you can find to use to test the input.

    There are String class methods which will do what you need. What are they? Are there class methods to test isAlphaNumeric()? Can you test an ascii value, or equals() a particular character?

Similar Threads

  1. Validation Problem
    By hshah in forum Java
    Replies: 1
    Last Post: 02-15-2006, 03:21 AM
  2. Control Array Validation
    By Miles Tones in forum VB Classic
    Replies: 2
    Last Post: 05-17-2005, 09:13 AM
  3. Replies: 0
    Last Post: 10-24-2001, 04:09 PM
  4. Replies: 2
    Last Post: 08-30-2001, 11:32 AM
  5. Validation
    By Marcia in forum Java
    Replies: 1
    Last Post: 09-14-2000, 11:04 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
  •  
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