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:
@@ -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"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user