0

In my Laravel 6.18 project, I have setup VueJS with Webpack manager.

I am working on client-side validation for validating User's Street Address in an application form.

I am using VeeValidate library of VueJS for validations, where we can provide the RegExp along with required validations separated by | symbol.

Now when I try to use the Regex [\w',-\\/.\s] in the application form with necessary character escaping as below, it gives the error SyntaxError: Invalid regular expression: /^[\w'/: Unterminated character class in the Browser's Console tab:

<input type="text"
    id="address"
    name="address"
    v-validate="'required|regex:^[\\w\'\,\-\/\.\\s]*$|max:75'"
    class="browser-default"
    required v-model="address"
    @blur="$emit('local-storage', 'address', address)"/>
<span class="missing-alert" v-show="errors.has('address')">Enter valid address</span>

Can anyone assist in understanding what's the syntactic error when using the said Regex inside Vue document textbox code ?

3
  • Try v-validate="'required|regex:/^[\\w\\/.\\',\\s-]*$/|max:75'" Commented Sep 21, 2020 at 16:16
  • That's not working, same error.. Commented Sep 21, 2020 at 19:02
  • Maybe v-validate="'required|regex:/^[\\w\\/.\\x27,\\s-]*$/|max:75'"? Commented Sep 21, 2020 at 20:03

1 Answer 1

1

Use the other form for specifying your rules - an Object, like so:

v-validate="{ required: true, regex:/^[\\w\'\,\-\/\.\\s]*$/, max:75 }"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.