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 3 of 3

Thread: How to validate a given URL

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    8
    My Mood
    Confused
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default How to validate a given URL

    Hi all,
    I want to validate componentTextField, if these field is null or left blank and click the enter button, it must display an error message. Also need to validate the URL that is entered.
    Can anyone help in this regard.
    Thanks in advance.
    Last edited by HelloAll; March 1st, 2011 at 01:23 AM.


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: How to validate a given URL

    Hello,

    Take a look at this code example - http://www.javaprogrammingforums.com...pressions.html

    You can put the code here:

        enterbutton.setText("Enter");
        gridConstraints.gridx = 1;
        gridConstraints.gridy = 5;
        getContentPane().add(enterbutton, gridConstraints);
        enterbutton.addActionListener(new ActionListener()
        {
        	public void actionPerformed(ActionEvent e)
        	{
        		enterbuttonActionPerformed(e);
        		// validate
        	}
        });

    You can check if something has been entered in the URLTextField by:

        		if(URLTextField.getText().equals("")){
        			//nothing has been entered
        		}
        		else{
        			//validate
        		}
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

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

    HelloAll (February 28th, 2011)

  4. #3
    Junior Member
    Join Date
    Jan 2011
    Posts
    8
    My Mood
    Confused
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Thumbs up Re: How to validate a given URL

    Thanks for your help. Using Regular expression was able to validate given URL.

Similar Threads

  1. Replies: 3
    Last Post: December 22nd, 2011, 09:46 AM
  2. Validate JSON according XSD schema
    By edrozim in forum Java Theory & Questions
    Replies: 2
    Last Post: February 23rd, 2011, 10:42 AM
  3. java validate help??
    By zyspt in forum Java Theory & Questions
    Replies: 1
    Last Post: April 16th, 2010, 02:48 AM
  4. Validate in server side..
    By Ganezan in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 27th, 2009, 06:36 AM
  5. Replies: 1
    Last Post: July 28th, 2009, 02:15 AM