我想驗證表單中的字段,以確保它包含鏈接到Vimeo視頻的URL的正確格式。下面是我在Javascript中的,但我需要將其轉換爲PHP(不是我的強項)簡單的PHP正則表達式問題
基本上,我需要檢查該字段,如果它的格式不正確,我需要將錯誤信息存儲爲變量..如果它是正確的,我將變量存儲爲空。
// Parse the URL
var PreviewID = jQuery("#customfields-tf-1-tf").val().match(/http:\/\/(www.vimeo|vimeo)\.com(\/|\/clip:)(\d+)(.*?)/);
if (!PreviewID) {
jQuery("#cleaner").html('<div id="vvqvideopreview"><?php echo $this->js_escape(__("Unable to parse preview URL. Please make sure it's the <strong>full</strong> URL and a valid one at that.", 'vipers-video-quicktags')); ?></div>');
return;
}
傳統VIMEO URL看起來是這樣的:http://www.vimeo.com/10793773
謝謝!
謝謝!你能告訴我如何將用戶輸入設置爲僅將vimeo id號碼設置爲變量嗎? – 2010-04-18 14:39:51
謝謝!效果很好。 – 2010-04-18 16:40:12