首页 > 解决方案 > VeeValidate - 如何验证应该使用 http:// 的 URL

问题描述

我试图通过以下方式验证我的输入:

<input 
     type="text"
     name="webhookURL"
     placeholder="Enter webhook URL"
     class="text-input"
     v-validate="'required|url'"
/>

但是如果我像这样填写输入,它会返回 true:google.com,所以如果我像这样填写http://exampleURL.com(使用 http:// 或 https://) ,我需要验证返回 true

标签: vuejs2vee-validate

解决方案


您必须使用require_protocol

<input v-validate="{url: {require_protocol: true }}"

文档


推荐阅读