Permalink
Browse files

Merge pull request #7430 from allstarschh/Bug828107

Bug 828107 - STK Get input does not accept pre-populated data
  • Loading branch information...
2 parents a9c7e41 + 5b305a0 commit 3c3c10419af9016a4fadda2ad2316323f0519f08 @vingtetun vingtetun committed Jan 9, 2013
Showing with 17 additions and 5 deletions.
  1. +17 −5 apps/settings/js/icc.js
@@ -562,9 +562,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({
@@ -574,8 +574,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);
@@ -601,6 +602,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 3c3c104

Please sign in to comment.