Results 1 to 2 of 2
  1. #1
    Bascotie is offline Member
    Join Date
    Apr 2008
    Posts
    88
    Rep Power
    0

    Default Validating for length of String

    Hey guys,

    I am following the project requirements for our first java project at school. One of the requirements is to validate it so that STATE cannot be blank and must have no more than two letters (like CA for california)

    I know how to validate for making sure the field is not blank but how about validating to make sure it is two characters long?

    Thanks, so far I have a "Customer" class that creates a Customer constructor, setters, getters, and returns a summary. Now I'm working on the validation and I've validated Firstname, last, address to make sure the fields are not blank.

    SOLVED the syntax is aCust.state.length != 2 where aCust is the object.
    Last edited by Bascotie; 10-11-2009 at 09:52 AM. Reason: solved

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. validating account
    By ServletEst in forum Java Servlet
    Replies: 3
    Last Post: 08-24-2009, 02:11 PM
  2. Replies: 1
    Last Post: 01-14-2009, 06:19 PM
  3. [SOLVED] String Length issue.
    By ChrisMayhew in forum New To Java
    Replies: 7
    Last Post: 01-11-2009, 04:16 AM
  4. Replies: 2
    Last Post: 03-25-2008, 06:49 AM
  5. validating a string for numbers and letters?
    By lockmac in forum New To Java
    Replies: 1
    Last Post: 08-09-2007, 10:17 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
  •