Reputation: 2183
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 ?
Upvotes: 0
Views: 288
Reputation: 21226
Use the other form for specifying your rules - an Object, like so:
v-validate="{ required: true, regex:/^[\\w\'\,\-\/\.\\s]*$/, max:75 }"
Upvotes: 1