我想验证表单中的一个字段,以确保它包含链接到 Vimeo 视频的 URL 的正确格式。以下是我在 Javascript 中的内容,但我需要将其转换为 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
谢谢!