Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Input verification suggestions?

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    5
    My Mood
    Where
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Smile Input verification suggestions?

    Nothing really that complicated, just a dilemma and everyone's opinions would be appreciated.

    Currently my program takes input from the user, their name. Before they can proceed though, there probably has to be some input verification first (at least that's what I'm thinking at the moment).

    Should I ban numbers or special symbols, or no restrictions at all?

    So far the only special symbols my program considers valid are '\'' and '-' and accepts letters and numbers.

    Do you think I should put any other restrictions, or remove the present one as mentioned above?

    (Small flaws in my program can't be risked, as it will be probed by a group of meticulous instructors).


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,332
    My Mood
    Hungover
    Thanks
    143
    Thanked 624 Times in 535 Posts

    Default Re: Input verification suggestions?

    This really depends entirely on the context of your program. If you're creating a little example program for fun and education, then it doesn't really matter. If you're creating some secure banking software or a nuclear missile controller, then you might have some more restrictions.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. The Following User Says Thank You to KevinWorkman For This Useful Post:

    lorenxvii (March 5th, 2014)

  4. #3
    Member
    Join Date
    Mar 2012
    Location
    United States
    Posts
    118
    My Mood
    Inspired
    Thanks
    1
    Thanked 33 Times in 31 Posts

    Default Re: Input verification suggestions?

    Should I ban numbers or special symbols, or no restrictions at all?
    That's personal preference unless there are specific guidelines. A common restriction is the number of characters and you could probably google for a list of other common restrictions as well.

    So far the only special symbols my program considers valid are '\'' and '-' and accepts letters and numbers.
    Seems like you already have something working. Best way to test this part of the program is to type something in that shouldn't be valid to be sure that the program catches it.

  5. The Following User Says Thank You to KucerakJM For This Useful Post:

    lorenxvii (March 5th, 2014)

  6. #4
    Junior Member
    Join Date
    Feb 2014
    Posts
    5
    My Mood
    Where
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Input verification suggestions?

    Quote Originally Posted by KevinWorkman View Post
    This really depends entirely on the context of your program. If you're creating a little example program for fun and education, then it doesn't really matter. If you're creating some secure banking software or a nuclear missile controller, then you might have some more restrictions.
    Well lol not really something that big, just a two-player game application with GUI.
    If it helps, my game has a leaderboard. Do you think it makes sense not to allow players to enter the same names each and every time they play the game? (Since during the game, if it's their turn their name will be displayed, if you get what I mean)

    --- Update ---

    Quote Originally Posted by KucerakJM View Post
    Seems like you already have something working. Best way to test this part of the program is to type something in that shouldn't be valid to be sure that the program catches it.
    Thanks! Yep that part about my program considering only (') and (-) valid among the other special symbols and accepting letters and numbers works; the part that makes me unsure about these restrictions is that names tend to be diverse, right? Like should I allow the players to enter purely numbers into the text field? Something like that.


    Quote Originally Posted by KucerakJM View Post
    A common restriction is the number of characters
    That does make sense, I'll add that, thanks again!
    Last edited by lorenxvii; March 5th, 2014 at 09:23 AM.

  7. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,332
    My Mood
    Hungover
    Thanks
    143
    Thanked 624 Times in 535 Posts

    Default Re: Input verification suggestions?

    Quote Originally Posted by lorenxvii View Post
    Well lol not really something that big, just a two-player game application with GUI.
    If it helps, my game has a leaderboard. Do you think it makes sense not to allow players to enter the same names each and every time they play the game?
    You tell me. Why wouldn't you allow a player to enter the same name twice?

    What problem are you trying to solve here? It seems like you're anticipating problems that haven't happened yet.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #6
    Junior Member
    Join Date
    Feb 2014
    Posts
    5
    My Mood
    Where
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Input verification suggestions?

    Quote Originally Posted by KevinWorkman View Post
    You tell me. Why wouldn't you allow a player to enter the same name twice?

    What problem are you trying to solve here? It seems like you're anticipating problems that haven't happened yet.
    I thought not to allow the players enter the same names since during the game, as each player takes his/her turn, his/her name will be displayed to indicate that it's his/her turn and I thought to avoid confusion for the players themselves, I'd do that check before they proceed to the game.

    And also, what if the player enters purely special symbols, like #%@%!#$#%. Do you think it should be considered invalid when what the program asks for is the player's name?
    Last edited by lorenxvii; March 5th, 2014 at 09:47 AM.

  9. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,332
    My Mood
    Hungover
    Thanks
    143
    Thanked 624 Times in 535 Posts

    Default Re: Input verification suggestions?

    Oh, you're talking about disallowing the players from entering the same name? Again, all of this is up to you, and there are ways around it. For example, you could display the names in different colors or automatically add a number to similar names.

    However, this is at best a corner case, and IMHO you're wasting time worrying too much about problems that haven't happened yet. You'd be much better off spending this time polishing your game and making it look better than trying to think of every corner case ahead of time.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  10. #8
    Junior Member
    Join Date
    Feb 2014
    Posts
    5
    My Mood
    Where
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Input verification suggestions?

    Quote Originally Posted by KevinWorkman View Post
    Oh, you're talking about disallowing the players from entering the same name? Again, all of this is up to you, and there are ways around it. For example, you could display the names in different colors or automatically add a number to similar names.

    However, this is at best a corner case, and IMHO you're wasting time worrying too much about problems that haven't happened yet. You'd be much better off spending this time polishing your game and making it look better than trying to think of every corner case ahead of time.
    Alright then! I'll probably consider that part about adding a number in the case of similar names.

    Yeah, I know I'm probably over-analyzing things; I've just been told to be preventive as much as possible

    Anyway, thanks for the time and help!

Similar Threads

  1. Verification Window "Do you really want to close?"
    By Wolfone in forum What's Wrong With My Code?
    Replies: 11
    Last Post: August 29th, 2013, 06:08 AM
  2. String verification.
    By Sylis in forum Java Theory & Questions
    Replies: 2
    Last Post: October 15th, 2012, 11:45 PM
  3. Project Idea / verification
    By zenaphor in forum Java Theory & Questions
    Replies: 4
    Last Post: July 3rd, 2012, 07:11 AM
  4. Scripting Rules for User verification
    By jwarren in forum Java Theory & Questions
    Replies: 0
    Last Post: June 29th, 2012, 08:26 AM
  5. Java - Crypto ISBN number verification, GUI program
    By djl1990 in forum What's Wrong With My Code?
    Replies: 11
    Last Post: October 13th, 2011, 11:22 AM

Tags for this Thread