How to validate url in javascript

Posted on 03.06.2019 by Admin
It returns true for correct URL address, else false. Now I want to check if selected type and entered url matches or not, like one should not be able to input the instagram url and select the url type as facebook.

The URL address is to be passed to a function while calling.

I tried to use one function to validate and it is working fine to validate the url but I want to also validate for facebook and instagram if it is photos url or video url. To validate URL address in JavaScript, use regex as in the following code. How to validate the url in javascript.
I have one input type to enter the url and one select tag to choose the url type. I want to check the URL address for protocol, domain name, port and query string. Jithin Wilfred, Between coding and designing.