scripts/formListener
Functions
Section titled “Functions”formListener()
Section titled “formListener()”function formListener( event: SubmitEvent, form: HTMLFormElement,type: "login" | "register"): Promise<void>
Defined in: studiocms/packages/studiocms/src/scripts/formListener.ts:18
Handles form submission events for login and registration forms.
Parameters
Section titled “Parameters”SubmitEvent
The submit event triggered by the form submission.
HTMLFormElement
The HTML form element being submitted.
The type of form being submitted, either ‘login’ or ‘register’.
"login"
| "register"
Returns
Section titled “Returns”Promise
<void
>
Remarks
Section titled “Remarks”- Prevents the default form submission behavior.
- For registration forms, checks if the password and confirm password fields match.
- Displays a toast notification if the passwords do not match.
- Submits the form data using the fetch API.
- Displays a success toast notification and reloads the page if the submission is successful.
- Displays an error toast notification if the submission fails.