Input

Input

Form component to enter date by keyboard

Constructor

new Input(data)

Parameters:
Name Type Description
data iInputConstructor

(Optional) Object with parameters.

Source:
Example
let fields = new Fields({
    title: "Phone Number",
    children: [
        new Txt("+"),
        new Input({type: "number", placeholder: "Prefix"}),
        new Input({type: "number", placeholder: "Number"}),
        new Button("Save")
    ]
});

Extends

Members

(static) regs

Properties:
Name Type Description
regs Object.<string, RegExp>

Library of regular expressions. Available by default: "email", "chars", "number", "float", "dd.mm.yyyy"

Source:

(static) types

Properties:
Name Type Description
types Object.<string, RegExp>

Library of functions to control (by press key event) entered symbols. Most of them use Field#regs. Available by default: "email", "chars", "number", "float", "int", "dd.mm.yyyy" (alias "date"), "date"

Source:

Methods

comment(value) → {string|undefined}

Get/Set comment.

Parameters:
Name Type Description
value string | undefined

String of comment

Overrides:
Source:

disabled(value) → {boolean|undefined}

Value "true" disable the Field.

Parameters:
Name Type Description
value boolean | undefined

Boolean value disable or enable the Field

Overrides:
Source:

error(value) → {string|undefined}

Get/Set value of error message.

Parameters:
Name Type Description
value string | undefined

String of placeholder

Overrides:
Source:
Example
let input = new Input();
input.status("error");
input.error("Invalid value");

name(value) → {string|undefined}

Get/Set name of Field-element. Methods Box#data and Box#form looking for Fields with defined this property only.

Parameters:
Name Type Description
value string | undefined

String of placeholder

Overrides:
Source:

placeholder(value) → {string|undefined}

Get/Set placeholder of element.

Parameters:
Name Type Description
value string | undefined

String of placeholder

Overrides:
Source:

status(value) → {string|undefined}

Get/Set particular style of element.

Parameters:
Name Type Description
value string | undefined

Available statuses: 'ok', 'error', 'accent', 'warn'

Overrides:
Source:

title(value) → {string|undefined}

Get/Set title of element.

Parameters:
Name Type Description
value string | undefined

String of title

Overrides:
Source:

type(value) → {string|undefined}

Get/Set type of Input field.

Parameters:
Name Type Description
value string | undefined

String with name of type. By default support Input#types but can be extended by custom rules.

Source:
Example
let input = new Input();
input.status("error");
input.error("Invalid value");

valid() → {boolean}

Get result of field validation.

Overrides:
Source:
Example
let input = new Input({
     value: "some@email.com",
     type: "email"
});
if (input.valid()) {
     console.log("Valid!");
}

validator() → {iValidatorClass}

method .valid() use validator if he is defined. The logic of validation inside iValidation class.

Overrides:
Source:

value(value) → {string|undefined}

Get/Set value of Field-element.

Parameters:
Name Type Description
value string | undefined

String of placeholder

Overrides:
Source: