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

  • SEARCH
  • Home
  • 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 6738735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:24:14+00:00 2026-05-26T11:24:14+00:00

I have an application where users have somewhat of a settings page, and some

  • 0

I have an application where users have somewhat of a settings page, and some of those settings allow URLs to be entered into them. I want to be able to run a check using javascript to make sure the URL they entered is valid and a real URL.

When they click submit, it will either do what it’s supposed to do, or if there’s an error in the URL, pop up with an alert and say “Invalid URL entered!”.

Is there a way to do this with JS? I also want this script to work with http:// and https:// as well as www. in the URL, and every domain extension (.com, .tv, etc.). This also needs to be done with JavaScript, not jQuery.

Can anyone show me how to do this? Thanks.

  • 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-05-26T11:24:15+00:00Added an answer on May 26, 2026 at 11:24 am

    It seems you’re wanting to do two things:

    1) Determine that the URL is valid (i.e. correctly formatted)

    For this a regular expression will work well, this approach will also allow you to retrieve various parts of the URL if that’s something you’d like to do.

    this has been discussed here: What is the best regular expression to check if a string is a valid URL?.

    2) Determine that the URL is real (i.e. if someone where to follow it they’d find something)

    This is more tricky, but you could attempt an AJAX request to the URL and if it fails or times out assume it’s down. There may be some limitations to this approach due to XSS security features on sites.

    If that’s a problem you could create a service of your own design that runs on a server that your JavaScript makes a request to, passing it the URL, and it responds with a failure or success.

    Here’s an example:

    verify.js

    function verifyURL (url) {
        // with jQuery
        $.getJSON('check-url.cgi', { url : url }, function (res) {
            console.log(res); // display server response
                if ( res.status == 'success' ) {
                   // URL is real
                } else {
                   // URL is not real
                }
        });
    }
    

    check-url.cgi

    #!/usr/bin/env perl
    use v5.10;
    use strict;
    use warnings;
    
    use CGI qw(:standard);
    use JSON::XS;
    use LWP::UserAgent;
    
    my $ua = LWP::UserAgent->new;
    $ua->agent("URL Checker/0.1");
    
    my $url    = param('url');
    my $req    = HTTP::Request->new(GET => $url);
    my $res    = $ua->request($req);
    my $status = $res->is_success ? 'success' : 'failure';
    
    print header('applicaton/json'), encode_json { status => $status };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that allow users to choose picture from native gallery then
I have an application with Users, Posts and Comments. Users has_many Posts, Posts has_many
I have an application where users can store items. Now each type of account
I have an application where users select their own display columns. Each display column
I have an application with Users, Machines, and Tests. Users have many Machines and
In my web application users have the ability to upload games which are then
I have an application where multiple users can login(not simultaneously though!only a single user
I have a silverlight application which users will be running in various time zones
We have an application that allows users to add/edit/replace/delete content (text, images, swfs, mp3s,
In my application I have Users, Organisations and Employees. There are domain objects for

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.