title: validate youtube URL using jquery javascript
body: <p>I want users to submit youtube URLs. I want to check "on the fly" if a youtube link is correct and change the text next to the input to OK if the check succeeds.</p>
  
  <p>I managed to make a validation function but it doesn't work. What am I doing wrong?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>It still doesnt work, it should say not ok when the URL is incorrect and OK when URL is correct while typing:</p>
  
  <pre><code>            $('form #youtube').bind("change keyup input", validYT());
          function validYT()
          {
  
              var url = $('form #youtube').val();
              var p = /^(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?(?=.*v=((\w|-){11}))(?:\S+)?$/;
              if (url.match(p)) {
                  $('#ytInfo').removeClass().addClass('fieldok ').text('OK');
                  return true
              }
              else
              {
                  $('#ytInfo').removeClass().addClass('fieldok ').text('NOT OK');
                  return false
              }
          }
  </code></pre>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>youtubelink&lt;BR&gt;
  &lt;input type="text" name="youtube" id ="youtube" value="" /&gt;&lt;div id="ytlInfo"&gt;dd&lt;/div&gt;
  </code></pre>