feat: Add validation for adventure name in CreateNewAdventure component

The code changes include adding validation for the adventure name in the CreateNewAdventure component. If the name is empty, an alert is displayed and the adventure creation is prevented. This enhancement ensures that users provide a name for the adventure before creating it.
This commit is contained in:
Sean Morley
2024-05-04 17:27:51 +00:00
parent 66d2dc7b15
commit 87cc6da518
2 changed files with 17 additions and 0 deletions

View File

@@ -26,6 +26,10 @@
function create() {
addActivityType();
if (newAdventure.name.trim() === "") {
alert("Name is required");
return;
}
dispatch("create", newAdventure);
console.log(newAdventure);
}
@@ -70,6 +74,7 @@
<input
type="text"
id="name"
required
bind:value={newAdventure.name}
class="input input-bordered w-full max-w-xs"
/>