Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7721721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:59:41+00:00 2026-06-01T03:59:41+00:00

I am trying to do some validation checks on inputs, which I’m having some

  • 0

I am trying to do some validation checks on inputs, which I’m having some issues with.
I need to be able to check that the url entered is valid, return it’s boolean value. If true it allows it to be assigned as myURL, else it will give me the JOptionPane message and stop. These will be checked from fields of entered data. This is part of a larger project, so any and all input is welcomed and appreciated.

public String SetURL (String a) {    
if (ValidateURL(a)) {
  myURL = a;
}
else {
  JOptionPane.showMessageDialog (null, "Sorry the URL: " + SetURL() + " is an invalid URL", 
                                 "Incorrect Information", JOptionPane.INFORMATION_MESSAGE);
}

}

  public Boolean ValidateURL () {
//Some code here to check the validation and return a true of false

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:59:43+00:00Added an answer on June 1, 2026 at 3:59 am

    You need to create both a URL object and a URLConnection object. The following code will test both the format of the URL and whether a connection can be established:

    try {
        URL url = new URL("http://www.yoursite.com/");
        URLConnection conn = url.openConnection();
        conn.connect();
    } catch (MalformedURLException e) {
        // the URL is not in a valid form
    } catch (IOException e) {
        // the connection couldn't be established
    }
    

    in your case, the catch will give you the JOptionPane message and stop, and you can even tell the user if it is because it’s malformed or unavailable

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to put together some Javascript form validation to check that all fields
I am trying to set up some validation, so that if the 'Yes' radio
I am trying to do some validation check to the password field a form.
Trying to setup some validation on the add to cart button for the dropdown
I am using VS 2010 RTM and trying to perform some basic validation on
I'm trying to add the jQuery Validation plugin to some websites and I'm running
I am trying some things with JSON and PHP and there is something that
I'm trying to do some validation on 2 numerical fields and not done much
I am trying to add some simple validation to my asp.net mvc form and
I am trying to perform validation on some fields by binding a function to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.