eachKey(function, scope)

Executes the specified function once for every key in the collection, passing each key, and its associated item as the first two parameters.

Parameters:

  • function : function to execute for each item.
  • scope (Object): (optional) scope in which to execute the function.


Example:

Validate all field values:

this.fields.eachKey(function(fieldName) {
var fieldInput = this.getFieldElement(fieldName);
if (valueExists(fieldInput)) {
var isValid = this.validateField(this.getFieldElementName(fieldName), true);
if (!isValid) {
this.addInvalidField(fieldName, '');
}
}
}