From fb796aacd263ab375f271a94570a47fe12a03c64 Mon Sep 17 00:00:00 2001 From: stasson Date: Mon, 15 Jan 2018 20:37:19 +0100 Subject: [PATCH] fix(textfield): add missing type attribute also fix required and add custom validation property closes #210 --- components/textfield/README.md | 30 +++++++++++++++++++++++++- components/textfield/mdc-textfield.vue | 20 +++++++++++++++-- components/unit-test/polyfills.js | 7 ++++++ 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/components/textfield/README.md b/components/textfield/README.md index 8c592cfe..89307ee1 100644 --- a/components/textfield/README.md +++ b/components/textfield/README.md @@ -12,7 +12,6 @@ var vm = new Vue({ text: "" } }) - ``` ### Help text @@ -57,6 +56,9 @@ var vm = new Vue({ ``` ### Validation + +- Native validation: use `type`, `required`, `minlength` and `maxlength` properties + ```html ``` +- Custom Validation: use `:valid` property: + +```html + +``` + +```javascript +var vm = new Vue({ + data: { + text: "" + } + computed: { + isValid () { + return myCustomCheck(this.text) + } + } +}) +``` + +> Once set, native validition is ignored. + ### props | props | Type | default | Description | @@ -81,6 +108,7 @@ var vm = new Vue({ |`required`| Boolean | | validation: whether this field is required| |`minlength`| [Number, String] | | validation: minimal length| |`maxlength`| [Number, String] | | validation: max length| +|`valid`| [Number, String] | | validation: custom validation property | |`size`| [Number, String] | 20 | textfield size (chars) | |`fullwidth`| Boolean | | whether the textfield is full width | |`multiline`| Boolean | | whether the textfield is multiline | diff --git a/components/textfield/mdc-textfield.vue b/components/textfield/mdc-textfield.vue index 69bad636..f050cde7 100644 --- a/components/textfield/mdc-textfield.vue +++ b/components/textfield/mdc-textfield.vue @@ -12,10 +12,11 @@