验证 Vimeo 剪辑 url
我想验证表单中的字段,以确保它包含链接到 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 网址如下所示:http://www.vimeo.com/10793773
I'd like to validate a field in a form to make sure it contains the proper formatting for a URL linking to a Vimeo video. Below is what I have in Javascript, but I need to convert this over to PHP (not my forte)
Basically, I need to check the field and if it is incorrectly formatted, I need to store an error message as a variable.. if it is correct, I store the variable empty.
// 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;
}
The traditional vimeo url looks like this: http://www.vimeo.com/10793773
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
更新,回复您的评论:
Update, in reply to your comment:
只需使用 preg_match 解析您的 $_REQUEST 即可。
Just parse your $_REQUEST with preg_match like.
尝试使用 https / http url
Try this for https / http url
要获取 Vimeo ID 号,您可以执行如下操作:
我还稍微更改了正则表达式,以保存过多的反斜杠转义字符。
To get at the Vimeo ID number, you could do something like the following:
I also slightly altered the regular expression, to save excessive backslash escape characters.