Added a validate file option and included documentation.
This commit is contained in:
parent
36f43805bd
commit
9d7ff647d2
@ -173,6 +173,8 @@ IgniteTemplate.prototype.validate = function (callback) {
|
|||||||
value = this.element.checked;
|
value = this.element.checked;
|
||||||
} else if (type == "number") {
|
} else if (type == "number") {
|
||||||
value = Number(this.element.value);
|
value = Number(this.element.value);
|
||||||
|
} else if (type == "file") {
|
||||||
|
value = this.element.files;
|
||||||
} else if (this.element.hasAttribute("contenteditable") && this.element.getAttribute("contenteditable").toLowerCase().trim() == "true") {
|
} else if (this.element.hasAttribute("contenteditable") && this.element.getAttribute("contenteditable").toLowerCase().trim() == "true") {
|
||||||
value = this.element.textContent;
|
value = this.element.textContent;
|
||||||
} else {
|
} else {
|
||||||
@ -327,6 +329,19 @@ IgniteTemplate.prototype.validateMatches = function (compare, msg) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates an input to make sure it contains at least one file file.
|
||||||
|
* @param {string|Function|IgniteProperty} msg The message to display when a file has not been selected.
|
||||||
|
* @returns {IgniteTemplate} This ignite template.
|
||||||
|
*/
|
||||||
|
IgniteTemplate.prototype.validateFile = function(msg) {
|
||||||
|
return this.validate((value, error) => {
|
||||||
|
if (!value || value.length == 0) {
|
||||||
|
return error(msg ? msg : 'Must select a file to upload.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates this element and all the children within the element.
|
* Validates this element and all the children within the element.
|
||||||
* @returns {Boolean} Whether or not this element and all children in this element are valid.
|
* @returns {Boolean} Whether or not this element and all children in this element are valid.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user