how to check the valid Youtube url using jquery

后端 未结 8 757
心在旅途
心在旅途 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:41

    You may try using a regular expression:

    var url = 'youtube.com/watch?v=FhnMNwiGg5M';
    var isyouTubeUrl = /((http|https):\/\/)?(www\.)?(youtube\.com)(\/)?([a-zA-Z0-9\-\.]+)\/?/.test(url);
    

提交回复
热议问题