diff --git a/src/components/AddItemForm.vue b/src/components/AddItemForm.vue index e2c1f24..1084f01 100644 --- a/src/components/AddItemForm.vue +++ b/src/components/AddItemForm.vue @@ -17,6 +17,7 @@ const item = reactive({ const form = ref(null); const submit = () => { + if (isValid.value === false) return; store.items.push({ name: item.name, price: item.price * 100, @@ -33,23 +34,31 @@ const submit = () => { label="Item Name" required v-model="item.name" + validate-on="blur" + :rules="[v => !!v || 'Item is required']" /> add item diff --git a/src/components/EditItemForm.vue b/src/components/EditItemForm.vue index cdd204e..071195d 100644 --- a/src/components/EditItemForm.vue +++ b/src/components/EditItemForm.vue @@ -21,6 +21,8 @@ const item = reactive({ const form = ref(null); const submit = () => { + console.log(isValid.value) + if (isValid.value === false) return; props.item.name = item.name; props.item.price = item.price * 100; props.item.user = store.users.find(user => user.name === item.user); @@ -35,23 +37,31 @@ const submit = () => { label="Item Name" required v-model="item.name" + validate-on="blur" + :rules="[v => !!v || 'Item is required']" /> edit item