A related question with an answer
Or this Regexp from Devshed:
function validURL(str) { var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string '(\\#[-a-z\\d_]*)?$','i'); // fragment locator return !!pattern.test(str); }
Related Posts:
- How to check whether a string contains a substring in JavaScript?
- Check if a string has a certain piece of text [duplicate]
- How to convert a string to an integer in JavaScript?
- How can I do string interpolation in JavaScript?
- How do I make the first letter of a string uppercase in JavaScript?
- How do I make the first letter of a string uppercase in JavaScript?
- Creating multiline strings in JavaScript
- Creating multiline strings in JavaScript
- Split string into array
- How do you reverse a string in-place in JavaScript?
- What is the correct way to check for string equality in JavaScript?
- Get the current URL with JavaScript?
- Encode URL in JavaScript?
- Check if a variable is a string in JavaScript
- What’s the best way to convert a number to a string in JavaScript?
- Check if a variable is a string in JavaScript
- How can I remove a character from a string using JavaScript?
- How to print elements from array with javascript
- How to remove text from a string?
- What does ${} (dollar sign and curly braces) mean in a string in Javascript?
- Delete first character of a string in Javascript
- ES6: Create Strings using Template Literals – Freecodecamp
- How do I check if string contains substring? [duplicate]
- How do I check if string contains substring?
- Get current URL with jQuery?
- How can I get the last character in a string?
- How can I get the last character in a string?
- Count the number of occurrences of a character in a string in Javascript
- Converting an object to a string
- Call Javascript function from URL/address bar
- Anagrams finder in javascript
- How do I modify the URL without reloading the page?
- How to interpolate variables in strings in JavaScript, without concatenation?
- How can I extract a number from a string in JavaScript?
- String.Format not work in TypeScript
- How to do case insensitive string comparison?
- Javascript isnull
- How to remove part of a string?
- Escaping HTML strings with jQuery
- Replace all spaces in a string with ‘+’
- How to open a URL using PHP?
- How to count string occurrence in string?
- Insert a string at a specific index
- Strip HTML from Text JavaScript
- How to check if the URL contains a given string?
- How to check if the URL contains a given string?
- Check if url contains string with JQuery
- Strip all non-numeric characters from string in JavaScript
- Wildcard string comparison in Javascript
- Replace spaces with dashes and make all letters lower-case
- Get query string parameters url values with jQuery / Javascript (querystring)
- How do I run code I have written in JavaScript?
- Error: Can’t set headers after they are sent to the client
- Array.size() vs Array.length
- Pure JavaScript equivalent of jQuery’s $.ready() – how to call a function when the page/DOM is ready for it [duplicate]
- Get String in YYYYMMDD format from JS date object?
- How to pop an alert message box using PHP?
- Node.js – SyntaxError: Unexpected token import
- Export html table data to Excel using JavaScript / JQuery is not working properly in chrome browser
- How to test valid UUID/GUID?
- Angular: Error no directive with “exportAs” set to “ngForm”
- How to implement authenticated routes in React Router 4?
- How to create a JQuery Clock / Timer
- Access Control Request Headers, is added to header in AJAX request with jQuery
- React Js: Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
- How to check if function exists in JavaScript?
- getBoundingClientRect is not a function
- Jquery button click() function is not working
- Make iframe automatically adjust height according to the contents without using scrollbar?
- How do I check whether a checkbox is checked in jQuery?
- Failed to find a valid digest in the ‘integrity’ attribute for resource on a deployed emberjs application
- Cannot read property ‘getHostNode’ of null
- TypeError: Class extends value undefined is not a function or null
- Eslint: How to disable “unexpected console statement” in Node.js?
- Get the Highlighted/Selected text
- Video auto play is not working in Safari and Chrome desktop browser
- Uncaught ReferenceError: ga is not defined
- Getting or changing CSS class property with Javascript using DOM style
- How to close a window using jQuery
- Javascript- Multiplying 2 numbers and return number
- What does the $() function do in JavaScript?
- How to add JavaScript code on WordPress properly?
- Disable unneeded scripts in a wordpress installation
- Restrict file types in the uploader of a wp.media frame
- Gutenberg getMedia() in post query doesn’t return all featured images
- Can I change an external script’s HTML?
- Adding and removing hidden buttons from WordPress Customizer Tinymce widget editor using javascript API
- Cannot use characters ” in jQuery script in WordPress
- How to install cool javascript feature in WordPress?
- Normal for scripts to be loaded after body tag?
- JS inside modal doesn’t work
- How to Get Post Meta in .Js File [duplicate]
- JavaScript problem in a WordPress PAGE
- Receive “menu-toogle” event from section menu in customizer
- Disable PAGESPEED SCRIPT INJECTION to IMAGE in theme files [closed]
- How to load JavaScript modules with script_loader_tag hook?
- Why is this script not working?
- How to securely set dynamic HTML content with JavaScript?
- Astra Mobile Cart Drawer is blank on home page
- How can I look at/edit what’s being sent to post.php when I hit the publish/update button?