Commit cdf23275 authored by Bryce Johnson's avatar Bryce Johnson

Add accessor for current val for convenience.

parent 80864a19
...@@ -68,9 +68,13 @@ ...@@ -68,9 +68,13 @@
} }
accessCurrentVal(newVal) {
return newVal ? this.inputElement.val(newVal) : this.inputElement.val();
}
handleInvalidInput(event) { handleInvalidInput(event) {
event.preventDefault(); event.preventDefault();
const currentValue = this.inputElement.val(); const currentValue = this.accessCurrentVal();
this.state.valid = false; this.state.valid = false;
this.state.empty = currentValue === ''; this.state.empty = currentValue === '';
...@@ -87,7 +91,7 @@ ...@@ -87,7 +91,7 @@
} }
updateValidityState() { updateValidityState() {
const inputVal = this.inputElement.val(); const inputVal = this.accessCurrentVal();
this.state.empty = !inputVal.length; this.state.empty = !inputVal.length;
this.state.valid = this.getInputValidity(); this.state.valid = this.getInputValidity();
this.renderValidity(); this.renderValidity();
...@@ -108,10 +112,10 @@ ...@@ -108,10 +112,10 @@
} }
setClearState() { setClearState() {
const inputVal = this.inputElement.val(); const inputVal = this.accessCurrentVal();
if (!inputVal.split(' ').length) { if (!inputVal.split(' ').length) {
const trimmedInput = this.inputElement.val().trim(); const trimmedInput = inputVal.trim();
this.inputElement.val(trimmedInput); this.accessCurrentVal(trimmedInput);
} }
this.inputElement.removeClass(inputErrorClass); this.inputElement.removeClass(inputErrorClass);
this.scopedSiblings.hide(); this.scopedSiblings.hide();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment