how to check the valid Youtube url using jquery

后端 未结 8 758
心在旅途
心在旅途 2020-12-10 14:02

In Jquery i want to check the specific url from youtube alone and show success status and others i want to skip by stating it as not valid url

var _videoUrl          


        
8条回答
  •  悲哀的现实
    2020-12-10 14:18

    You can check if URL contains the word "http://www.youtube.com" using .indexOf()

    var url = 'http://www.youtube.com/channel/UChh-akEbUM8_6ghGVnJd6cQ';
    if (url.indexOf('http://www.youtube.com') > -1) {
      alert( "true");
    } else {
      alert( "false");
    }
    

提交回复
热议问题