Complete the code to bind the input value to the variable.
<input type="text" bind:value=[1] />
Binding the input's value to username allows Svelte to track the input's content.
Complete the code to check if the password length is at least 8 characters.
{#if [1].length >= 8}
<p>Password is strong enough.</p>
{/if}We check the length of the password variable to validate its strength.
Fix the error in the form submission handler to prevent default behavior.
<form on:submit=[1]>
<!-- form fields -->
</form>Using on:submit|preventDefault stops the form from reloading the page on submit.
Fill both blanks to create a reactive statement that updates isValid when email changes.
<script> let email = ''; let isValid = false; $: isValid = [1].includes('@') && [2].includes('.'); </script>
The reactive statement updates isValid based on the email variable's content.
Fill all three blanks to create a form with validation that disables the submit button if the form is invalid.
<script> let email = ''; let password = ''; $: isFormValid = [1].includes('@') && [2].length >= 8; </script> <form> <input type="email" bind:value=[3] aria-label="Email address" required /> <input type="password" bind:value={password} aria-label="Password" required /> <button type="submit" disabled={!isFormValid}>Submit</button> </form>
The form checks if email contains '@' and password is at least 8 characters. The submit button disables if invalid.