Class

VPFieldset

VPFieldset()

VPFieldset Instance

Constructor

# new VPFieldset()

Fieldset instances are responsible for managing the relationship between fields. Fieldset instances are capable of validating fields based upon a relationship, such as checkbox/radio fields being interdependent.

View Source Fieldset.ts, line 64

Examples
// DOM Bindings, All Fields must validate true
<div id="sample_fieldset" class="VPFieldset" vp-find>
  <div class="VPField" vp-notify="false">
    <input id="first-name" aria-label="First Name" name="first-name" type="text" required="required" />
  </div>

  <div class="VPField" vp-notify="false">
    <input id="last-name" aria-label="Last Name" name="last-name" type="text" required="required" />
  </div>
</div>
// DOM Bindings, One field must be true
<div id="sample_fieldset" class="VPFieldset" vp-strategy="one" vp-find>
 <div class="VPField">
   <label for="option_one">
     <input id="option_one" name="option-one" type="radio" value="one" required="required" />
     Option #1
   </label>
 </div>

 <div class="VPField">
   <label for="option_two">
     <input id="option_two" name="option-two" type="radio" value="two" required="required" />
     Option #2
   </label>
 </div>

 <div class="VPField">
   <label for="option_three">
     <input id="option_three" name="option-three" type="radio" value="three" required="required" />
     Option #3
   </label>
 </div>
</div>
// Programmic bindings
const fieldset = new VP.Fieldset(document.getElementById('sample_fieldset'), {
   ValidationStrategy: "one"
});
const option_one_field = new VP.Field(document.getElementsById('field_one'))
const option_two_field = new VP.Field(document.getElementsById('field_two'))
const option_three_field = new VP.Field(document.getElementsById('field_three'))
fieldset.addField(option_one_field);
fieldset.addField(option_two_field);
fieldset.addField(option_three_field);

Extends

Classes

VPFieldset

Methods

# addEventListener(event_name, callback)

Add an event listener

Parameters:
Name Type Description
event_name string

Name of the event

callback EventCallback

Event callback to fire

Overrides:

View Source mixins/EventEmitter.ts, line 22

# addField(field, indexopt)

Add a field instance to be tracked

Parameters:
Name Type Attributes Description
field VPField

Field to track

index number <optional>

Indicate the field order to track by

View Source Fieldset.ts, line 216

# addMessage(message, statusopt)

Adds a unique message to the $MessageNode

Parameters:
Name Type Attributes Description
message

The message to append

status <optional>

An optional class to append indicating message status

Overrides:

View Source lib/DOMMessaging.ts, line 104

If the $MessageNode isn't set or isn't an HTMLElement

# addMessages(messages, statusopt)

Batch append messages

Parameters:
Name Type Attributes Description
messages

The messages to append

status <optional>

An optional class to append indicating message status

Overrides:

View Source lib/DOMMessaging.ts, line 125

If the $MessageNode isn't set or isn't an HTMLElement

# clearMessages()

Clear all messages from the $MessageNode (If set)

Overrides:

View Source lib/DOMMessaging.ts, line 146

# createEvent(event_name, options) → {Event}

Helper for creating a new event, supporting IE9

Parameters:
Name Type Description
event_name string

Name of the event

options EventOptions

Event options

Overrides:

View Source mixins/EventEmitter.ts, line 70

Event

# createField(el, options)

Helper method for creating a new Field to automatically track

Parameters:
Name Type Description
el HTMLElement

Field Element

options VPFieldOptions

Options to apply to the field instance

View Source Fieldset.ts, line 227

# dispatchEvent(event, data) → {boolean}

Include support for passing data along event

Parameters:
Name Type Description
event Event

the Event object to dispatch

data any

Data to be passed to the callback

Overrides:

View Source mixins/EventEmitter.ts, line 52

boolean

# findFields(fieldOptionsopt)

Helper for automatically parsing child elements for Fields

Parameters:
Name Type Attributes Description
fieldOptions VPFieldOptions | Array.<VPFieldOptions> <optional>

Options to apply to the found fields. If array, options will apply based on index

View Source Fieldset.ts, line 239

# generateMessageNode(anchoropt, posopt)

Generate a messageNode where messages can be added and removed in a managed way.

Parameters:
Name Type Attributes Description
anchor <optional>

The anchor to use for the $MessageNode (Defaults to $MessageAnchor)

pos <optional>

The position to set $MessageNode inside the $MessageAnchor

Overrides:

View Source lib/DOMMessaging.ts, line 68

If anchor isn't an Element

If pos isn't a valid

VerticalPosition

# isElementVisible(element)

Helper method to determine if the element is visible within the DOM

Parameters:
Name Type Description
element HTMLElement

Element to test

Overrides:

View Source Validatable.ts, line 149

boolean

# isValid()

Standard Validation cycle for the Fieldset instance.

  • Validation will validate all tracked Fields
  • Validation will return as either synchronous validation or asynchronous based on field responses.
  • If Lazy, validation will stop at the first error

View Source Fieldset.ts, line 155

(boolean|Promise.)

# removeEventListener(event_name, callback) → {EventCallback|null}

Remove an event listener

Parameters:
Name Type Description
event_name string

Name of the event

callback EventCallback

The event callback to remove

Overrides:

View Source mixins/EventEmitter.ts, line 34

EventCallback | null

# removeField(field)

Remove a tracked field from this fieldset

Parameters:
Name Type Description
field VPField

Field instance to remove

View Source Fieldset.ts, line 196

# removeMessage(message)

Remove a message

Parameters:
Name Type Description
message

The message to remove

Overrides:

View Source lib/DOMMessaging.ts, line 135

If the $MessageNode isn't set or isn't an HTMLElement

# removeMessageNode()

Removes the $MessageNode from the $MessageAnchor

Overrides:

View Source lib/DOMMessaging.ts, line 92

If the $MessageNode isn't set or isn't an HTMLElement

# scrollTo()

Scroll to the tracked element

Overrides:

View Source Validatable.ts, line 86