Spaces:
Configuration error
Configuration error
File size: 1,101 Bytes
38ae87f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | <script>
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
let username = '';
let email = '';
let phone = '';
let latitude = '';
let longitude = '';
function submitForm() {
if (!username || !email) {
alert('Please fill in required fields: Username, Email.');
return;
}
dispatch('addUser', {
username,
email,
phone,
latitude: parseFloat(latitude) || null,
longitude: parseFloat(longitude) || null
});
username = email = phone = latitude = longitude = '';
}
</script>
<form on:submit|preventDefault={submitForm}>
<h2>Register User</h2>
<input placeholder="Username *" bind:value={username} required />
<input type="email" placeholder="Email *" bind:value={email} required />
<input placeholder="Phone Number" bind:value={phone} />
<input placeholder="Latitude (optional)" bind:value={latitude} type="number" step="any" />
<input placeholder="Longitude (optional)" bind:value={longitude} type="number" step="any" />
<button type="submit">Add User</button>
</form>
|