Other usage

Only one error message

Instead of displaying individual error messages for each rule, it is possible to display only one error message.

Kensho.config.verbose = false

const kensho = new Kensho('form')
kensho.add({
    inputElement : '.my-input',
    errorElement : '.my-error',
    errorMessage : 'it is invalid.',
    rule : ['my-rule1', 'my-rule2'],
    event : ['keyup']
})

The value of the errorMessage property of the parameter passed to the `kensho.add()` method must be a string or { default : 'error message' }. If errorMessage is omitted, the default error message will be displayed.

Delaying the search for Custom Attributes

Normally, when an instance of Kensho is created, the cusotm Attributes described in the form are searched and registered to the instance as a "rule unit". However, by passing option.search = false to the constructor, the search and registration can be done manually.

const kensho = yokotak0527.Kensho('form', { search : false })

// something codes...

kensho.addFromCustomAttrs(kensho.search())

Last updated