user13729875
user13729875

Reputation:

How to validate an url using vee validate

I started working on a small project using Vue.js and Vee Validate, and i would like to validate a domain name but i get an error message : ( url rule not exists )

<ValidationObserver v-if="currentStep === 1">
                                    <ValidationProvider name="URL" rules="required|url" v-slot="{ errors }">
                                        <div class="form-group">
                                            <input class="form-control" v-model="website_url" type="text" placeholder="Your email" />
                                            <span>{{ errors[0] }}</span>
                                        </div>
                                    </ValidationProvider>
                                </ValidationObserver>

Upvotes: 1

Views: 1131

Answers (1)

tuhin47
tuhin47

Reputation: 6058

You code seemes like you want to validate URL as a email. You need to validate like this:

<input name="url" v-model="website_url" v-validate="'required|url'" :class="{'input': true, 'is-danger': errors.has('url') }" type="text" placeholder="Website">

Here is a demo for website

Upvotes: 1

Related Questions