Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2009
    Posts
    7
    Rep Power
    0

    Question Asking for a username with conditions

    Hey,
    I'm fairly new to Java and i'm having to cram a truckload worth of it into my tiny tiny brain in first semester for my course.
    I want to read and store a user name chosen by the user, however, I want to implement restrictions on what characters must be included:
    an example is that it must start with a letter, contain at least one digit, contain at least one symbol or punctuation mark, between 4 and 8 characters
    and must not contain spaces.
    I used a (Character.isLetter(userName.charAt(0))==false) line to check whether the first character is a letter and
    (userName.indexOf(" ") for the spaces. However no matter how hard I try i cannot seem to figure out how to implement the other restrictions.
    Any feedback on this would be much appreciated.
    cheers

  2. #2
    faisalcmpm is offline Member
    Join Date
    Feb 2009
    Posts
    22
    Rep Power
    0

    Default

    Try with Regular expressions

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

Similar Threads

  1. password username and databases
    By chalo in forum JCreator
    Replies: 0
    Last Post: 12-02-2008, 09:11 AM
  2. username password verification
    By bheezee in forum JDBC
    Replies: 0
    Last Post: 11-25-2008, 07:55 PM
  3. [SOLVED] if else conditions not working. T_T
    By uncanny in forum Advanced Java
    Replies: 4
    Last Post: 10-17-2008, 06:44 AM
  4. Replies: 9
    Last Post: 09-30-2008, 08:30 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
  •