From 22ac59e04a506cce4660fe1ffb610981bad55d41 Mon Sep 17 00:00:00 2001 From: Icebob Date: Wed, 1 Mar 2017 10:42:30 +0100 Subject: [PATCH] Fix #137 (number input validation) --- dev/full/app.vue | 2 +- dev/full/schema.js | 3 ++- src/fields/core/fieldInput.vue | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dev/full/app.vue b/dev/full/app.vue index 47d49131..bf2ffbac 100644 --- a/dev/full/app.vue +++ b/dev/full/app.vue @@ -69,7 +69,7 @@ formOptions: { validateAfterLoad: true, - validateAfterChanged: false, + validateAfterChanged: true, validateBeforeSave: true } } diff --git a/dev/full/schema.js b/dev/full/schema.js index f9817293..0c18ab00 100644 --- a/dev/full/schema.js +++ b/dev/full/schema.js @@ -117,7 +117,8 @@ module.exports = { inputType: "number", label: "Number", model: "age", - styleClasses: "half-width" + styleClasses: "half-width", + validator: validators.number }, { type: "input", inputType: "range", diff --git a/src/fields/core/fieldInput.vue b/src/fields/core/fieldInput.vue index 36f77e62..6607d579 100644 --- a/src/fields/core/fieldInput.vue +++ b/src/fields/core/fieldInput.vue @@ -4,7 +4,6 @@ :type="schema.inputType", :value="value", @input="value = $event.target.value", - number="schema.inputType == 'number'", :disabled="disabled", :accept="schema.accept", :alt="schema.alt", @@ -65,6 +64,8 @@ return fecha.parse(value, "YYYY-MM-DD HH:mm:ss"); case "datetime-local": return fecha.parse(value, "YYYY-MM-DDTHH:mm:ss"); + case "number": + return Number(value); } }