Permalink
Browse files

Bug 828107 - STK Get input does not accept pre-populated data

  • Loading branch information...
1 parent 39caebc commit 5b305a098e12ed8755efa0664868b0875aa6a947 @allstarschh allstarschh committed Jan 9, 2013
Showing with 17 additions and 5 deletions.
  1. +17 −5 apps/settings/js/icc.js
View
@@ -498,9 +498,9 @@
var button = document.createElement('button');
button.id = 'stk-item-' + 'ok';
button.textContent = 'Ok';
- if (options.minLength) {
- button.disabled = true;
- }
+ button.disabled = !checkInputLengthValid(input.value.length,
+ options.minLength,
+ options.maxLength);
button.onclick = function(event) {
var value = document.getElementById('stk-item-input').value;
responseSTKCommand({
@@ -510,8 +510,9 @@
};
input.onkeyup = function(event) {
- button.disabled = (input.value.length < options.minLength) ||
- (input.value.length > options.maxLength);
+ button.disabled = !checkInputLengthValid(input.value.length,
+ options.minLength,
+ options.maxLength);
};
label.appendChild(button);
@@ -520,6 +521,17 @@
}
/**
+ * Check the length of the input is valid.
+ *
+ * @param inputLen The length of the input.
+ * @param minLen Minimum length required of the input.
+ * @param maxLen Maximum length required of the input.
+ */
+ function checkInputLengthValid(inputLen, minLen, maxLen) {
+ return (inputLen >= minLen) && (inputLen <= maxLen);
+ }
+
+ /**
* Display text to the user
*/
function displayText(command, cb) {

0 comments on commit 5b305a0

Please sign in to comment.