Any1 good with Java?
Results 1 to 5 of 5

Thread: Any1 good with Java?

  1. #1
    Join Date
    Oct 2002

    Any1 good with Java?

    Hey there,

    I'm currently doing a piece of coursework for uni involving Java, but i've hit a brick wall, and any help would be appreciated.

    I am writing a web page that is a registration form, which asks the user for thier name, address, email, password etc. I have done this and also got it to verify each field isnt blank (if it is an alert pops up), and i have verified the email address is of a valid format and that the password and the verify password match.

    What i need from some helpful person is 2 things :-

    1)I need to verify fields such as the name field that no numbers have been input and also the telephone number field to make sure no letters or characters have been entered.

    2) Once everything has been verified etc, i want a pop up box to say sumthin like, "these are the details you entered", and i need the box to display all the details in the one box (name,address, phone, email etc, but obviously not password).

    ANY help would be greatly recieved,


  2. #2
    Senior Member
    Join Date
    Nov 2002
    Hopefully you are familiar with exceptions. The best way to verify a number field is all numbers, is to read the data as a string, and then attempt to cast it to an integer. Do this in a try{} block and attempt to catch(NumberFormatException e){}. Basically if the exception is caught, there are characters in the string.
    To verify the character field contains no numbers is to use a for loop to traverse the string, and make sure each character is not a number (using a really long if statement). There might be a better way, but I can't remember.
    The best way to pop up a dialog box is to use the Dialog class.(there are a lot of details involved in using this object, but you can find them out at the URL below)
    More info on all of these classes can be found at:
    (This is quite possibly the best java reference site ever)
    Good luck!
    \"When you say best friends, it means friends forever\" Brand New
    \"Best friends means I pulled the trigger
    Best friends means you get what you deserve\" Taking Back Sunday

  3. #3
    Join Date
    Oct 2002
    I'm really new when doing java, so what u have said is above me. I understand the scripts as there basically c, which i have experience in, so does any1 else have any advice.

    Thanks again mate

  4. #4
    Join Date
    Mar 2003

    Lightbulb Regular Expresions

    If you are familiar with perl you should know what a regular expression is. but briefly itīs a way to handle strings and characters, itīs the most powerful tool of perl.
    Java also provides a Regex object wich allows you to make those kinds of verification a lot easier and more effective.
    try searching java regular expressions . (believe me itīs very useful)

    good luck

  5. #5
    Antionline Herpetologist
    Join Date
    Aug 2001
    OK, first off, it's obvious that you're talking about JavaScript here and not Java. That's what's got the other guys confused a bit. I've yet to see someone implement a HTML form in Java (not because it can't be done, but because it's overkill. So just use a variation of the following code:
    <script language="JavaScript">
    var name, number;
    function validateInput()
    		alert("Please type only numbers in the \"number\" field");
    		alert("The values you typed are : \nName="+name+"\nNumber="+number);
    <form name="form1" action="submit.php" method="post">
    Name : <input type="text" name="txt_name">
    Number : <input type="text" name="txt_number">
    <input type="button" name="btn_submit" value="submit" onClick=validateInput()>
    <input type="reset">
    If you only want integers, just replace parseFloat(number) with parseInt(number);

    Buy the Snakes of India book, support research and education (sorry the website has been discontinued)
    My blog:

Posting Permissions

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