Benefits of Using a and sign up or log in.
https://fabform.io/f/your-form-id
Step 3: Integrate the Form in Svelte
Now that you have the Fabform action URL, integrate the form into your Svelte app by replacing the form’s action attribute with the URL provided by Fabform.
Here’s the Svelte form code:
<script>
let formData = {
name: '',
email: '',
message: ''
};
</script>
<main>
<h1>Contact Form</h1>
<form
action="https://fabform.io/f/your-form-id" <!-- Replace with your Fabform URL -->
method="POST"
on:submit|preventDefault>
<!-- Optional: Redirect URL after submission -->
<input type="hidden" name="redirect_to" value="https://your-redirect-url.com" />
<!-- Name Field -->
<div>
<label for="name">Name</label>
<input
type="text"
id="name"
name="name"
bind:value={formData.name}
required
/>
</div>
<!-- Email Field -->
<div>
<label for="email">Email</label>
<input
type="email"
id="email"
name="email"
bind:value={formData.email}
required
/>
</div>
<!-- Message Field -->
<div>
<label for="message">Message</label>
<textarea
id="message"
name="message"
bind:value={formData.message}
required
></textarea>
</div>
<button type="submit">Submit</button>
</form>
</main>
<style>
main {
padding: 20px;
font-family: Arial, sans-serif;
}
form {
max-width: 500px;
margin: 0 auto;
}
div {
margin-bottom: 10px;
}
label {
display: block;
margin-bottom: 5px;
}
input, textarea {
width: 100%;
padding: 8px;
font-size: 16px;
}
button {
padding: 10px 15px;
font-size: 16px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
</style>
Key Details:
Action URL: The form'sactionURL should be replaced with the URL from Fabform. This is where your form data will be submitted.
Form Fields: Thenameattributes of the fields (name,email,message) should match the field names configured in your Fabform form.
Optional Redirect: You can include a hiddenredirect_tofield to define where users are sent after the form is submitted.
Step 4: Test the Form
- Run the Svelte app:
npm run dev
- Open the browser and navigate to
http://localhost:5000. - Fill out the form and submit. Fabform will handle the submission and either redirect the user to the specified URL or show a confirmation page.
Using Fabform.io provides a simple, secure way to handle form submissions without needing to manage a backend. By embedding Fabform's form action URL into your Svelte app, you can easily collect and manage form submissions. Plus, Fabform’s integrations with services like Google Sheets and email makes it even more powerful for handling the data.
SOCIAL SHARE CARD GENERATOR