Class: InputControl

hcje/domTools.InputControl(config)

Input control. This provides a text input field.

Constructor

new InputControl(config)

Construct the input control. For more details on the configuration options, see input text type.

Parameters:
Name Type Description
config Object
Properties
Name Type Attributes Default Description
parentElement Element

Element to attach to.

label string

Label for the control

initialValue number <optional>
0

Initial value.

maxLength number

Maximum length of the input

minLength number

Minimum length of the input

placeholder string

Hint for input.

onChange module:hcje/domTools.InputControl~onChangeCallback

Function to call on change.

constrain module:hcje/domTools~ConstrainInput | string

Function to call on input. If a string is provided, it should be the name of an in-built function: FLOAT, +FLOAT, INT or +INT. These in-built functions are case insensitive. Those preceded by + character constrain the input to positive values. If an initial value and constraint are provided, the initial value is parsed by the constrain function before use.

Source:

Extends

  • module:hcje/domTools.BaseControl

Methods

constrainToRegex(regex, lastValidInput, currentInput) → {string}

Regex constraint. This tests the current input against a regular expression and returns the current input if the test passes or the lastValidInput if it fails.

Parameters:
Name Type Description
regex RegExp

Regex to test input against.

lastValidInput string

Last valid input.

currentInput string

Current input.

Source:
Returns:
Type
string

getValue() → {string}

Get current value as string.

Source:
Returns:
Type
string

Type Definitions

onChangeCallback(value)

Callback function for a InputControl.

Parameters:
Name Type Description
value string

Current value

Source: