Verify an image URL in JavaScript

In this short article, we will show you how to verify an image URL in JavaScript.

Here, we will use the Regular Expression to validate the image url using JavaScript.

Use the following function to check the extension using a regular expression.

Function

Here we have validated the extension such as jpg, jpeg, gif, and png. This function will return the boolean value.

Output

In the upcoming article, we will show you how to check if an image exists from a URL.

That’s it for today.
Thank you for reading. Happy Coding..!! 🙂

If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *