Input

Inputs that accept typed input from users

Contents

Validation

Input field is a component that encounters the most amount of user errors. To help avoid users from making repeated errors on inputs, it’s important to consider to:

- Write a helpful placeholder example.

- Use a helper text after the user has made an error.

- Highlight the input field box with a distinctive colour (typically red).

- Write a helpful error message that communicate to the user on how to fix the error.

- Dynamic validation - First validation happens only on blur, and validates on keyup once an error exists.

Dynamic validation

Typically, the behaviour of these error validations are shown after the user has interacted with a field. In some cases, a helper text is shown before the interaction occurs, to clear any confusion. For example, some countries use (MM/DD/YYYY) format while other countries use (DD/MM/YYYY) format.

Error

If an input requires validation from the back-end to check if the user’s details are correct, display an error message for the user to re-enter to avoid the user having to search through the whole form to find the invalid input.

Custom error

If an input requires a custom error message, display it instead of the default error message. Set the customValidationError input to the custom error template. This is useful when you want to display a custom error message with additional elements. Try typing 'custom' into the input field and validate to see the custom error message.

Display Validation

By default, the validation error message is displayed below the input field. If you want to hide the validation error message, you can set the displayValidation input to false. This is useful when you'll use fl-input within a new component that has its own validation.

Note: If you set the displayValidation input to false, you must display the validation error message in the new component yourself.

Errors on sign up and log-in flow

Recently, Freelancer.com has introduced a series of validation messages through different stages of the validation behaviour to improve the experience of correcting an error on the sign up and log-in flow.

The validation is shown in three stages:

Error: The error message is shown after the user has entered the wrong input.

Warning: After the user sees the error and goes to correct their input, an orange helper message is shown to guide the user how to fix the error.

Success: When the user enters the right input format, the field is highlighted in green.

Inputs in Validation
customValidationError ?: TemplateRef<HTMLElement>
displayValidation ?: boolean = true
dynamicValidation ?: boolean = false

First validation happens only on blur, and validates on keyup once an error exists

Also set in this example
control : FormControl<T>
type : IsAny<T> extends true ? any : [T] extends [number] ? InputType.NUMBER | InputType.NUMBER_INCREMENT : [T] extends [string] ? InputType.CURRENCY | ... 4 more ... | InputType.SEARCH : never

Declared as an `@Input()` by each concrete component, which narrows it to the types that component actually renders. Not an input on its own.

label ?: string

Sets aria label for accessibility when there is no associated visible text

placeholder ?: string
Outputs
iconEndClick ?: any = new EventEmitter<MouseEvent>()
iconStartClick ?: any = new EventEmitter<MouseEvent>()
onBlur ?: any = new EventEmitter<void>()
onFocus ?: any = new EventEmitter<void>()