Forms

Fundamental feature that allows users to input data and interact with a website. HPUCSS Forms powered by Float Labels

Default Form Style

The default form behavior. The label floats on top of each field.

Programmatic Form

Forms can be activated programmatically with options available to customize their behavior. When using this approach, simply add the id attribute to the <form> parent element, then call that id into your script.

Form Options

Form options to change the floating behavior of each field:

JS



let form = new HPU.Form('#formId', {options});

// Manually enable the defined form
form.floatLabels();

Forms with Background Colors

Apply contrasting color against the background color for better visibility. For each of the .input-group, add the matching color used on the background by adding the class .bg-{color}. For example, if the background color used is .hpu-bg-1st, then the .input-group must have the class .bg-1st to give the input field contrast. See HPUCSS Colors for color usage guides.

Form Validation

Form feedback to show users if the input is meeting the required pattern or not.

TIP: To use floating style validation, apply the novalidate attribute in the form opening tag to avoid the default HTML validation.

Also, .helper-text class can also be set. For each of the .input-group underneath the input, select, or textarea, provide a span with .helper-text class to show validation messages whether error or success messages.

Lastly, add either the .valid or .invalid class to the label, input|select|textarea, and the .helper-text to show the validation feedback styles.

Looks Good!
Looks Good!
Invalid Email
City not found!
Please select a state
Invalid Zip!