# Code to check the condition of video link

**URL:** <https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527>\
**Category:** Questions about Thunkable X\
**Created:** [July 24, 2021, 6:23pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527 "2021-07-24T18:23:05Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![19manharan1fbs7](https://avatars.discourse-cdn.com/v4/letter/1/ecc23a/32.png) [@19manharan1fbs7](https://community.thunkable.com/u/19manharan1fbs7)\
**Post date:** [July 24, 2021, 6:23pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527/1 "2021-07-24T18:23:05Z")

</div>

Hi  
I am making an app in which I want to give an option to the user to upload the youtube link which will be further saved in the database.  
However, I am unable to understand which condition to put in order to check whether the link is of youtube only. If not then show an alert by saying “Enter the valid youtube link”.  
Kindly help me to solve this. 🙂

---

<div class="post-metadata">

**Author:** ![skulamester](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/skulamester/32/100480_2.png) [@skulamester](https://community.thunkable.com/u/skulamester)\
**Post date:** [July 24, 2021, 6:35pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527/2 "2021-07-24T18:35:25Z")

</div>

Hi there,

Maybe you can check if the link contains the word “youtube”.

There is a block for that.

---

<div class="post-metadata">

**Author:** ![19manharan1fbs7](https://avatars.discourse-cdn.com/v4/letter/1/ecc23a/32.png) [@19manharan1fbs7](https://community.thunkable.com/u/19manharan1fbs7)\
**Post date:** [July 24, 2021, 6:48pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527/3 "2021-07-24T18:48:39Z")

</div>

I used the block 'in text “abc” contain “b” ’ but it did not work.

---

<div class="post-metadata">

**Author:** ![skulamester](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/skulamester/32/100480_2.png) [@skulamester](https://community.thunkable.com/u/skulamester)\
**Post date:** [July 24, 2021, 7:00pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527/4 "2021-07-24T19:00:22Z")

</div>

How did you try the block? Could you attach a screenshot?

---

<div class="post-metadata">

**Author:** ![19manharan1fbs7](https://avatars.discourse-cdn.com/v4/letter/1/ecc23a/32.png) [@19manharan1fbs7](https://community.thunkable.com/u/19manharan1fbs7)\
**Post date:** [July 24, 2021, 7:10pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527/5 "2021-07-24T19:10:43Z")

</div>

sure

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/0/50511967b9eb141b1056804a67c2db10f303e9f5.png)  
This is the screenshot of the condition I tried to imply.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [July 24, 2021, 7:15pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527/6 "2021-07-24T19:15:08Z")

</div>

I went to youtube and shared a video link.  
I got this `https://youtu.be/V_Kr9OSfDeU`  
See that it does not contain the text you are looking for and therefore the condition you created will **fail**.

---

<div class="post-metadata">

**Author:** ![19manharan1fbs7](https://avatars.discourse-cdn.com/v4/letter/1/ecc23a/32.png) [@19manharan1fbs7](https://community.thunkable.com/u/19manharan1fbs7)\
**Post date:** [July 24, 2021, 7:16pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527/7 "2021-07-24T19:16:31Z")

</div>

> [@muneer](#):
>
> [https://youtu](https://youtu)

I tried to put the condition to find only “[https://youtu](https://youtu)” much of text from the link to but still it did not work.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [July 24, 2021, 7:21pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527/8 "2021-07-24T19:21:46Z")

</div>

You are trying to test the `Input from the user` so you can get any type of text which you cannot predict.  
A user could type “youtube” without the “https:” part. You made the control entirely to the user.

---

<div class="post-metadata">

**Author:** ![19manharan1fbs7](https://avatars.discourse-cdn.com/v4/letter/1/ecc23a/32.png) [@19manharan1fbs7](https://community.thunkable.com/u/19manharan1fbs7)\
**Post date:** [July 24, 2021, 7:23pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527/9 "2021-07-24T19:23:23Z")

</div>

the how will I verify that whether the user is putting youtube link only ?

---

<div class="post-metadata">

**Author:** ![skulamester](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/skulamester/32/100480_2.png) [@skulamester](https://community.thunkable.com/u/skulamester)\
**Post date:** [July 24, 2021, 7:26pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527/10 "2021-07-24T19:26:31Z")

</div>

In addition to that, the true at the end is unnecessary

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [July 24, 2021, 7:52pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527/11 "2021-07-24T19:52:32Z")

</div>

You need to check the possible combinations not only one. such as `youtube.com. www.youtube.com, youtu.be, .....`.

If I were you I would put the possible combinations in a list and then check every entry in the list against user entry.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [July 24, 2021, 8:22pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527/12 "2021-07-24T20:22:24Z")

</div>

What is your intention? If you verify that a YouTube link _could_ be valid because it meets all those requirements, it still may not be a link that displays an actual video.

For example, this link is valid (`https://www.youtube.com/watch?v=bRzNufidtpY`):

[![](https://img.youtube.com/vi/bRzNufidtpY/maxresdefault.jpg "Michael's Second Job - The Office US") ](https://www.youtube.com/watch?v=bRzNufidtpY)

This one, where I change one character, is not (`https://www.youtube.com/watch?v=bRzMufidtpY`):

[![]( " - YouTube") ](https://www.youtube.com/watch?v=bRzMufidtpY)

One way to check for valid formatting is to use [Javascript](https://irishdotnet.dev/how-to-validate-a-youtube-url-using-javascript) (or Thunkable). But that doesn’t address the problem I brought up.

---

<div class="post-metadata">

**Author:** ![jonathonschnoor6x4b5](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jonathonschnoor6x4b5/32/112262_2.png) [@jonathonschnoor6x4b5](https://community.thunkable.com/u/jonathonschnoor6x4b5)\
**Post date:** [July 24, 2021, 10:35pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527/13 "2021-07-24T22:35:22Z")

</div>

You might just want to search for “youtu” _and_ “.com/”

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:17pm UTC](https://community.thunkable.com/t/code-to-check-the-condition-of-video-link/1412527/14 "2024-11-08T13:17:50Z")

</div>


