Skip to main content

import SubmitAutomaticallyExample from "../../components/Demos/SubmitAutomaticallyExample";

title: Examples toc_min_heading_level: 2 toc_max_heading_level: 5


Examples

Basic


Check out the code
<form id="basic_form" autocomplete="off" novalidate="novalidate">
<div class="control-wrapper">
<label class="input-label" for="basic_name">Name</label>
<div class="input-wrapper">
<input
id="basic_name"
class="input"
autocomplete="off"
type="text"
placeholder="Enter your name"
/>
</div>
</div>
<div class="control-wrapper">
<label class="input-label" for="basic_email">Email</label>
<div class="input-wrapper">
<input
id="basic_email"
class="input"
autocomplete="off"
type="text"
placeholder="Enter your email"
/>
</div>
</div>
<div class="control-wrapper">
<label class="input-label" for="basic_password">Password</label>
<div class="input-wrapper">
<input
id="basic_password"
class="input"
autocomplete="off"
type="text"
placeholder="Enter your password"
/>
</div>
</div>
<div class="control-wrapper">
<label class="input-label" for="basic_age">Age</label>
<div class="input-wrapper">
<input
id="basic_age"
class="input"
autocomplete="off"
type="text"
placeholder="Enter your age"
/>
</div>
</div>
<div class="control-wrapper">
<button type="submit" class="button">Submit</button>
</div>
</form>


Advanced

You should give us your consent
Please select at least 1 option
Please select the preferred way for communication

Check out the code
<form id="advanced-usage_form" autocomplete="off" novalidate="novalidate">
<div class="control-wrapper">
<label class="input-label" for="advanced-usage_password">Password</label>
<div class="input-wrapper">
<input
id="advanced-usage_password"
class="input"
autocomplete="off"
type="password"
placeholder="Enter password"
/>
</div>
</div>
<div class="control-wrapper">
<label class="input-label" for="advanced-usage_repeat-password"
>Repeat password</label
>
<div class="input-wrapper">
<input
id="advanced-usage_repeat-password"
class="input"
autocomplete="off"
type="password"
placeholder="Repeat password"
/>
</div>
</div>
<div class="control-wrapper">
<label class="input-label" for="advanced-usage_message">Message</label>
<div class="input-wrapper">
<textarea
id="advanced-usage_message"
class="input textarea"
placeholder="Enter message"
></textarea>
</div>
</div>
<div class="control-wrapper">
<label class="input-label" for="advanced-usage_favorite_animal_select"
>Select you favorite animal</label
>
<div class="input-wrapper">
<select class="select minimal" id="advanced-usage_favorite_animal_select">
<option value="">--Please select an option--</option>
<option value="Dog">Dog</option>
<option value="Cat">Cat</option>
<option value="Hamster">Hamster</option>
<option value="Parrot">Parrot</option>
<option value="Spider">Spider</option>
<option value="Goldfish">Goldfish</option>
</select>
</div>
</div>
<div class="control-wrapper mb-32">
<div class="label mb-8">You should give us your consent</div>
<div class="control-wrapper">
<div class="flex">
<input
type="checkbox"
id="advanced-usage_consent_checkbox"
class="checkbox"
/><label
class="input-label ml-8 pb-0"
for="advanced-usage_consent_checkbox"
>I agree to provide the information</label
>
</div>
<div id="advanced-usage_consent_checkbox-errors-container"></div>
</div>
</div>
<div
class="control-wrapper mb-32"
id="advanced-usage_communication_checkbox_group"
>
<div class="label mb-8">Please select at least 1 option</div>
<div class="control-wrapper">
<div class="flex">
<input
type="checkbox"
id="advanced-usage_communication_checkbox_group_1"
class="checkbox"
name="communication_checkbox_group"
/><label
class="input-label ml-8 pb-0"
for="advanced-usage_communication_checkbox_group_1"
>I'd like to receive news by email</label
>
</div>
<div
id="advanced-usage_communication_checkbox_group_1-errors-container"
></div>
</div>
<div class="control-wrapper">
<div class="flex">
<input
type="checkbox"
id="advanced-usage_communication_checkbox_group_2"
class="checkbox"
name="communication_checkbox_group"
/><label
class="input-label ml-8 pb-0"
for="advanced-usage_communication_checkbox_group_2"
>I'd like to receive news by post</label
>
</div>
<div
id="advanced-usage_communication_checkbox_group_2-errors-container"
></div>
</div>
<div class="control-wrapper">
<div class="flex">
<input
type="checkbox"
id="advanced-usage_communication_checkbox_group_3"
class="checkbox"
name="communication_checkbox_group"
/><label
class="input-label ml-8 pb-0"
for="advanced-usage_communication_checkbox_group_3"
>I'd like to receive news by text phone</label
>
</div>
<div
id="advanced-usage_communication_checkbox_group_3-errors-container"
></div>
</div>
</div>
<div class="control-wrapper mb-16">
<div class="label mb-8">
Please select the preferred way for communication
</div>
<div id="advanced-usage_communication_radio_group">
<div class="control-wrapper">
<label class="input-label flex"
><input
type="radio"
id="advanced-usage_communication_radio_group_1"
class="radio"
name="communication_radio_group"
/>
<span class="ml-8">Email</span></label
>
</div>
<div class="control-wrapper">
<label class="input-label flex"
><input
type="radio"
id="advanced-usage_communication_radio_group_2"
class="radio"
name="communication_radio_group"
/>
<span class="ml-8">Text message</span></label
>
</div>
</div>
</div>
<div class="control-wrapper">
<label class="input-label" for="advanced-usage_input_number"
>Input any number</label
>
<div class="input-wrapper">
<input
id="advanced-usage_input_number"
class="input"
autocomplete="off"
type="text"
placeholder="Input any number"
/>
</div>
</div>
<div class="control-wrapper">
<label class="input-label" for="advanced-usage_input_integer_number"
>Input an integer number</label
>
<div class="input-wrapper">
<input
id="advanced-usage_input_integer_number"
class="input"
autocomplete="off"
type="text"
placeholder="Input an integer number"
/>
</div>
</div>
<div class="control-wrapper">
<label class="input-label" for="advanced-usage_input_number_between"
>Input a number between 10 and 20</label
>
<div class="input-wrapper">
<input
id="advanced-usage_input_number_between"
class="input"
autocomplete="off"
type="text"
placeholder="Input a number between 10 and 20"
/>
</div>
</div>
<div class="control-wrapper">
<button type="submit" class="button">Submit</button>
</div>
</form>


Async validation


Check out the code
<form id="async_form" autocomplete="off" novalidate="novalidate">
<div class="control-wrapper">
<label class="input-label" for="async_email">Email</label>
<div class="input-wrapper">
<input
id="async_email"
class="input"
autocomplete="off"
type="text"
placeholder="Enter your email"
/>
</div>
</div>
<div class="control-wrapper">
<button type="submit" class="button">Submit</button>
</div>
</form>


Tooltips

Please confirm you agree
Please select at least 1 option
Please select your preferred contact method

Check out the code
<form id="tooltips_form" autocomplete="off" novalidate="novalidate">
<div class="row">
<div class="col">
<div class="control-wrapper">
<label class="input-label" for="tooltips_name">Name</label>
<div class="input-wrapper">
<input
id="tooltips_name"
class="input"
autocomplete="off"
type="text"
placeholder="Enter your name"
/>
</div>
</div>
</div>
<div class="col">
<div class="control-wrapper">
<label class="input-label" for="tooltips_email">Email</label>
<div class="input-wrapper">
<input
id="tooltips_email"
class="input"
autocomplete="off"
type="text"
placeholder="Enter your email"
/>
</div>
</div>
</div>
</div>
<div class="control-wrapper">
<label class="input-label" for="tooltips_favorite_animal_select"
>Select you favorite animal</label
>
<div class="input-wrapper">
<select class="select minimal" id="tooltips_favorite_animal_select">
<option value="">--Please select an option--</option>
<option value="Dog">Dog</option>
<option value="Cat">Cat</option>
<option value="Hamster">Hamster</option>
<option value="Parrot">Parrot</option>
<option value="Spider">Spider</option>
<option value="Goldfish">Goldfish</option>
</select>
</div>
</div>
<div class="control-wrapper mb-32">
<div class="label mb-8">Please confirm you agree</div>
<div class="control-wrapper">
<div class="flex">
<input
type="checkbox"
id="tooltips_consent_checkbox"
class="checkbox"
/><label class="input-label ml-8 pb-0" for="tooltips_consent_checkbox"
>I agree to provide the information</label
>
</div>
<div id="tooltips_consent_checkbox-errors-container"></div>
</div>
</div>
<div class="control-wrapper mb-32" id="tooltips_communication_checkbox_group">
<div class="label mb-8">Please select at least 1 option</div>
<div class="control-wrapper">
<div class="flex">
<input
type="checkbox"
id="tooltips_communication_checkbox_group_1"
class="checkbox"
name="communication_checkbox_group"
/><label
class="input-label ml-8 pb-0"
for="tooltips_communication_checkbox_group_1"
>I'd like to receive news by email</label
>
</div>
<div id="tooltips_communication_checkbox_group_1-errors-container"></div>
</div>
<div class="control-wrapper">
<div class="flex">
<input
type="checkbox"
id="tooltips_communication_checkbox_group_2"
class="checkbox"
name="communication_checkbox_group"
/><label
class="input-label ml-8 pb-0"
for="tooltips_communication_checkbox_group_2"
>I'd like to receive news by post</label
>
</div>
<div id="tooltips_communication_checkbox_group_2-errors-container"></div>
</div>
<div class="control-wrapper">
<div class="flex">
<input
type="checkbox"
id="tooltips_communication_checkbox_group_3"
class="checkbox"
name="communication_checkbox_group"
/><label
class="input-label ml-8 pb-0"
for="tooltips_communication_checkbox_group_3"
>I'd like to receive news by text phone</label
>
</div>
<div id="tooltips_communication_checkbox_group_3-errors-container"></div>
</div>
</div>
<div class="control-wrapper mb-16">
<div class="label mb-8">Please select your preferred contact method</div>
<div id="tooltips_communication_radio_group">
<div class="control-wrapper">
<label class="input-label flex"
><input
type="radio"
id="tooltips_communication_radio_group_1"
class="radio"
name="communication_radio_group"
/>
<span class="ml-8">Email</span></label
>
</div>
<div class="control-wrapper">
<label class="input-label flex"
><input
type="radio"
id="tooltips_communication_radio_group_2"
class="radio"
name="communication_radio_group"
/>
<span class="ml-8">Text message</span></label
>
</div>
</div>
</div>
<div class="control-wrapper">
<button type="submit" class="button">Submit</button>
</div>
</form>


Localisation


Check out the code
<form id="localisation_form" autocomplete="off" novalidate="novalidate">
<div>
<div class="control-wrapper">
<label class="input-label" for="localisation_language"
>Change error messages language</label
>
<div class="input-wrapper">
<select class="select minimal" id="localisation_language">
<option value="">--Please select an option--</option>
<option value="English" selected="">English</option>
<option value="Spanish">Spanish</option>
<option value="French">French</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="control-wrapper">
<label class="input-label" for="localisation_form_name">Name</label>
<div class="input-wrapper">
<input
id="localisation_form_name"
class="input"
autocomplete="off"
type="text"
placeholder="Enter your name"
/>
</div>
</div>
</div>
<div class="col">
<div class="control-wrapper">
<label class="input-label" for="localisation_form_email">Email</label>
<div class="input-wrapper">
<input
id="localisation_form_email"
class="input"
autocomplete="off"
type="text"
placeholder="Enter your email"
/>
</div>
</div>
</div>
</div>
<div class="control-wrapper">
<button type="submit" class="button">Submit</button>
</div>
</form>


Conditional fields


Check out the code
<form id="conditional_form" autocomplete="off" novalidate="novalidate">
<div class="control-wrapper">
<div class="control-wrapper">
<label class="input-label" for="conditional_name">Name</label>
<div class="input-wrapper">
<input
id="conditional_name"
class="input"
autocomplete="off"
type="text"
placeholder="Enter your name"
/>
</div>
</div>
</div>
<div class="control-wrapper">
<div class="control-wrapper">
<div class="flex">
<input
type="checkbox"
id="conditional_checkbox"
class="checkbox"
/><label class="input-label ml-8 pb-0" for="conditional_checkbox"
>Name is required</label
>
</div>
<div id="conditional_checkbox-errors-container"></div>
</div>
</div>
<div class="control-wrapper">
<button type="submit" class="button">Submit</button>
</div>
</form>


Date validation using text input


Check out the code
<form id="date-text_form" autocomplete="off" novalidate="novalidate">
<div class="control-wrapper">
<div class="control-wrapper">
<label class="input-label" for="date-text_start_date">Start date</label>
<div class="input-wrapper">
<input
id="date-text_start_date"
class="input"
autocomplete="off"
type="text"
placeholder="Enter start date"
/>
</div>
</div>
</div>
<div class="control-wrapper">
<div class="control-wrapper">
<label class="input-label" for="date-text_between_date"
>Between date</label
>
<div class="input-wrapper">
<input
id="date-text_between_date"
class="input"
autocomplete="off"
type="text"
placeholder="Enter between date"
/>
</div>
</div>
</div>
<div class="control-wrapper">
<div class="control-wrapper">
<label class="input-label" for="date-text_end_date">End date</label>
<div class="input-wrapper">
<input
id="date-text_end_date"
class="input"
autocomplete="off"
type="text"
placeholder="Enter end date"
/>
</div>
</div>
</div>
<div class="control-wrapper">
<div class="control-wrapper">
<label class="input-label" for="date-text_format"
>Check for dd MMM yyyy format</label
>
<div class="input-wrapper">
<input
id="date-text_format"
class="input"
autocomplete="off"
type="text"
placeholder="Enter a valid date"
/>
</div>
</div>
</div>
<div class="control-wrapper">
<button type="submit" class="button">Submit</button>
</div>
</form>


Files validation


Check out the code
<form id="files_form" autocomplete="off" novalidate="novalidate">
<div class="control-wrapper">
<div class="control-wrapper">
<label class="input-label" for="files_minmax">Upload 1-3 files</label>
<div class="input-wrapper">
<input
id="files_minmax"
class="input"
autocomplete="off"
type="file"
multiple=""
/>
</div>
</div>
</div>
<div class="control-wrapper">
<div class="control-wrapper">
<label class="input-label" for="files_png">Upload 1 png file</label>
<div class="input-wrapper">
<input id="files_png" class="input" autocomplete="off" type="file" />
</div>
</div>
</div>
<div class="control-wrapper">
<div class="control-wrapper">
<label class="input-label" for="files_attr"
>Upload several png/jpg/jpeg files with min size 10kb and max size
25kb</label
>
<div class="input-wrapper">
<input
id="files_attr"
class="input"
autocomplete="off"
type="file"
multiple=""
/>
</div>
</div>
</div>
<div class="control-wrapper">
<button type="submit" class="button">Submit</button>
</div>
</form>


Render errors in a custom container

Custom container for Name field
Please select at least 1 option
Please select your preferred contact method

Check out the code
<form id="errors-container_form" autocomplete="off" novalidate="novalidate">
<div class="row">
<div class="col">
<div class="control-wrapper">
<label class="input-label" for="errors-container_name">Name</label>
<div class="input-wrapper">
<input
id="errors-container_name"
class="input"
autocomplete="off"
type="text"
placeholder="Enter your name"
/>
</div>
</div>
<div class="control-wrapper">
<span>Custom container for Name field</span>
<div id="errors-container_custom-name"></div>
</div>
</div>
<div class="col">
<div class="control-wrapper">
<label class="input-label" for="errors-container_email">Email</label>
<div class="input-wrapper">
<input
id="errors-container_email"
class="input"
autocomplete="off"
type="text"
placeholder="Enter your email"
/>
</div>
</div>
</div>
</div>
<div
class="control-wrapper mb-32"
id="errors-container_communication_checkbox_group"
>
<div class="label mb-8">Please select at least 1 option</div>
<div class="control-wrapper">
<div class="flex">
<input
type="checkbox"
id="errors-container_communication_checkbox_group_1"
class="checkbox"
name="communication_checkbox_group"
/><label
class="input-label ml-8 pb-0"
for="errors-container_communication_checkbox_group_1"
>I'd like to receive news by email</label
>
</div>
<div
id="errors-container_communication_checkbox_group_1-errors-container"
></div>
</div>
<div class="control-wrapper">
<div class="flex">
<input
type="checkbox"
id="errors-container_communication_checkbox_group_2"
class="checkbox"
name="communication_checkbox_group"
/><label
class="input-label ml-8 pb-0"
for="errors-container_communication_checkbox_group_2"
>I'd like to receive news by post</label
>
</div>
<div
id="errors-container_communication_checkbox_group_2-errors-container"
></div>
</div>
<div class="control-wrapper">
<div class="flex">
<input
type="checkbox"
id="errors-container_communication_checkbox_group_3"
class="checkbox"
name="communication_checkbox_group"
/><label
class="input-label ml-8 pb-0"
for="errors-container_communication_checkbox_group_3"
>I'd like to receive news by text phone</label
>
</div>
<div
id="errors-container_communication_checkbox_group_3-errors-container"
></div>
</div>
</div>
<div class="control-wrapper mb-16">
<div class="label mb-8">Please select your preferred contact method</div>
<div id="errors-container_communication_radio_group">
<div class="control-wrapper">
<label class="input-label flex"
><input
type="radio"
id="errors-container_communication_radio_group_1"
class="radio"
name="communication_radio_group"
/>
<span class="ml-8">Email</span></label
>
</div>
<div class="control-wrapper">
<label class="input-label flex"
><input
type="radio"
id="errors-container_communication_radio_group_2"
class="radio"
name="communication_radio_group"
/>
<span class="ml-8">Text message</span></label
>
</div>
</div>
</div>
<div class="control-wrapper" id="errors-container_custom-container"></div>
<div class="control-wrapper">
<button type="submit" class="button">Submit</button>
</div>
</form>


Manually added errors


Check out the code
<form id="manual_form" autocomplete="off" novalidate="novalidate">
<div class="control-wrapper">
<label class="input-label" for="manual_name">Name</label>
<div class="input-wrapper">
<input
id="manual_name"
class="input"
autocomplete="off"
type="text"
placeholder="Enter your name"
/>
</div>
</div>
<div class="control-wrapper">
<div class="control-wrapper">
<button type="button" class="button" data-variant="negative">
Show error label
</button>
</div>
<div class="control-wrapper">
<button type="button" class="button" data-variant="success">
Show success label
</button>
</div>
</div>
<div class="control-wrapper">
<button type="submit" class="button">Submit</button>
</div>
</form>


Validate before submitting


Check out the code
<form id="before-submit_form" autocomplete="off" novalidate="novalidate">
<div class="control-wrapper">
<label class="input-label" for="before-submit_email">Email</label>
<div class="input-wrapper">
<input
id="before-submit_email"
class="input"
autocomplete="off"
type="text"
placeholder="Start typing..."
/>
</div>
</div>
<div class="control-wrapper">
<button type="submit" class="button">Submit</button>
</div>
</form>

Submit form automatically


Check out the code
<form id="submit-automatically_form" autocomplete="off" novalidate="novalidate">
<div class="control-wrapper">
<label class="input-label" for="submit-automatically_form_email"
>Email</label
>
<div class="input-wrapper">
<input
id="submit-automatically_form_email"
class="input"
autocomplete="off"
type="text"
placeholder="Start typing..."
/>
</div>
</div>
<div class="control-wrapper">
<button type="submit" class="button">Submit</button>
</div>
</form>