Sha256: 6a563f40404279c11b54cb60f7a6a9091d90ccd5ae79020c5e823d5d35428e57
Contents?: true
Size: 706 Bytes
Versions: 5
Compression:
Stored size: 706 Bytes
Contents
export class RequiredFields { // Monitors the form and runs the callback if any of the required fields change constructor(form, callback) { this.form = form this.callback = callback this.reload() } get areComplete() { return this.requiredFields.filter((n, elem) => { return this.isValuePresent(elem) } ).length == 0 } isValuePresent(elem) { return ($(elem).val() === null) || ($(elem).val().length < 1) } // Reassign requiredFields because fields may have been added or removed. reload() { // ":input" matches all input, select or textarea fields. this.requiredFields = this.form.find(':input[required]') this.requiredFields.change(this.callback) } }
Version data entries
5 entries across 5 versions & 2 rubygems