Apologies in advance as I know there are so many answers to this question however I have not been successful with implementing any of the given answers. With that being said, let's get to the issue.
I have a table containing text inputs where user enters youtube video ids
Onsubmit my javascript will create an array containing these youtube video ids
If user enters a youtube url, the array breaks
Quick Solution
If someone can help me get the regex validation to work so the user will be alerted properly and correct their input that would be a good start
Ideal Solution
I'm not fond of alerting users and making them change what they've entered as its bad user experience so if anyone is feeling extra helpful today and could show me how to take what they enter and strip out the url bits and push only the youtube video id to the array that would be super wonderful :)
example: if user entered
["https://www.youtube.com/watch?v=K1CScQOj1dA", "https://youtu.be/wIJ1sFrgMds", "IISzG-sPUuo"]
the code would format their inputs and the final userSongs
array would be:
["K1CScQOj1dA", "wIJ1sFrgMds", "IISzG-sPUuo"]
Here is my fiddle http://jsfiddle.net/1qLr9n2j/
As you can see, the alert says no match when two of the inputs are invalid entries