Deprecated: Validates form fields and values against the registration form as defined in the site Dashboard.
Deprecation note: The validate()
function of the RsvpForm
object is being deprecated.
Use the validate()
function of the Form
object instead.
The validate()
function returns a Promise that resolves to {valid: true}
if the fields and values in the RSVP form are valid or rejects if there are
invalid fields or values.
You can validate your form explicitly using the validate()
function. Validation
is also implicitly performed when you call the submit()
function. When
the validate()
function is called, explicitly or implicitly, the validateInput()
function also runs for all your form fields.
The following are invalid when checked against the event's registration form as defined in the site Dashboard:
Note: To work with the Wix Events API, you need to publish your site.
function validate(formValues: Array<FormValue>): Promise<ValidationResult>;
Field names and values for an RSVP form.
import wixEventsFrontend from 'wix-events-frontend';
// ...
const eventId = // Get the event ID
const form = wixEventsFrontend.createEventRsvpForm(eventId);
// ...
let formValues = // get form values
form.validate(formValues)
.then((response) => {
// handle case where form is valid
})
.catch((error) => {
// handle case where form is not valid
let message = error.message; // "Following fields have invalid IDs: nonExistent1, nonExistent2"
let fields = error.fields; // ["nonExistent1", "nonExistent2"]
});
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.