Reputation: 4282
I'd like to validate a form using vue-js 2.3
and element-ui
Apparently, they use async-validator to validate the form. The documentation is here.
https://jsfiddle.net/skd3nyqh/
Uncaught Error: Unknown rule type D*([2-9]d{2})(D*)([2-9]d{2})(D*)(d{4})D*
I do not know how to validate a field with regexp
. I find the documentation not explicit enough on that topic.
Upvotes: 8
Views: 18059
Reputation: 82489
From the documentation.
Pattern
The pattern rule property indicates a regular expression that the value must match to pass validation.
Use
{required: true, pattern:/\D*([2-9]\d{2})(\D*)([2-9]\d{2})(\D*)(\d{4})\D*/, message: 'Please input phone', trigger: 'blur' }
Updated fiddle.
Upvotes: 12