Auto input focusing not working in iOS (works in android) with Cordova
up vote
0
down vote
favorite
I am building an app with Cordova, for both of iOS and Android.
I have a page where I have 3 inputs, each input, will take 1 digit to make a code.
Something like: 123
So in the first input you would type '1', it would jump to the next input and focus on it, so you could type the '2'.
This behaviour works fine in Android!
Same code doesn't seem to work for iOS though.
I have the following html:
<form class="matrixZone">
<div class="CardList optionMenu fullRowInput">
<input class="mb20" type="tel" id="new_auth1" move-next-input ng-model="operation.authorizationCodeConfirm[0]" ng-click="newCodeAutorizationfocus(1)" ng-change="changeFocus(2)" maxlength="1" style="-webkit-text-security: disc; text-security: disc;">
<input class="mb20" type="tel" id="new_auth2" move-next-input ng-model="operation.authorizationCodeConfirm[1]" ng-click="newCodeAutorizationfocus(2)" ng-change="changeFocus(3)" maxlength="1" style="-webkit-text-security: disc; text-security: disc;">
<input class="mb20" type="tel" id="new_auth3" move-next-input ng-model="operation.authorizationCodeConfirm[2]" ng-click="newCodeAutorizationfocus(3)" ng-change="changeFocus(4)" maxlength="1" style="-webkit-text-security: disc; text-security: disc;">
</div>
</form>
For the directive move-next-input I have:
function moveNextInput() {
return {
restrict: 'A',
link: function ($scope, element) {
element.on("input", function (e) {
if (element.val().length == element.attr("maxlength")) {
var $nextElement = element.next();
if ($nextElement.length) {
$nextElement[0].focus();
$nextElement[0].click();
}
}
}).keyup(function (e) {
if (e.which === 8 && !this.value) {
$(this).prev().focus();
$(this).prev().click();
}
});
And I have the following functions as well (on the controller):
$scope.changeFocus = function (n) {
if (n === 0) {
var id = "new_auth3";
var element = $window.document.getElementById(id);
if (element) {
if (isNaN($scope.operation.authorizationCodeConfirm[2]) || $scope.operation.authorizationCodeConfirm[2] == "")
return;
element.blur();
$scope.oldMCCStr = getMCC($scope.operation.authorizationCodeConfirm);
$('#new_auth1').focus
console.log("esta a ser chamado!");
}
}
};
// checks if the key pressed is a number
var checkInput = function (inputArr) {
angular.forEach(inputArr, function (value, key) {
if (null !== inputArr[key]) {
var compare = parseInt(inputArr[key]);
if (isNaN(compare)) {
inputArr[key] = '';
}
}
});
};
$scope.$watch('operation.authorizationCodeConfirm', function (newValue, oldValue) {
checkInput($scope.operation.authorizationCodeConfirm);
console.log("esta a ser chamado!");
}, true);
add a comment |
up vote
0
down vote
favorite
I am building an app with Cordova, for both of iOS and Android.
I have a page where I have 3 inputs, each input, will take 1 digit to make a code.
Something like: 123
So in the first input you would type '1', it would jump to the next input and focus on it, so you could type the '2'.
This behaviour works fine in Android!
Same code doesn't seem to work for iOS though.
I have the following html:
<form class="matrixZone">
<div class="CardList optionMenu fullRowInput">
<input class="mb20" type="tel" id="new_auth1" move-next-input ng-model="operation.authorizationCodeConfirm[0]" ng-click="newCodeAutorizationfocus(1)" ng-change="changeFocus(2)" maxlength="1" style="-webkit-text-security: disc; text-security: disc;">
<input class="mb20" type="tel" id="new_auth2" move-next-input ng-model="operation.authorizationCodeConfirm[1]" ng-click="newCodeAutorizationfocus(2)" ng-change="changeFocus(3)" maxlength="1" style="-webkit-text-security: disc; text-security: disc;">
<input class="mb20" type="tel" id="new_auth3" move-next-input ng-model="operation.authorizationCodeConfirm[2]" ng-click="newCodeAutorizationfocus(3)" ng-change="changeFocus(4)" maxlength="1" style="-webkit-text-security: disc; text-security: disc;">
</div>
</form>
For the directive move-next-input I have:
function moveNextInput() {
return {
restrict: 'A',
link: function ($scope, element) {
element.on("input", function (e) {
if (element.val().length == element.attr("maxlength")) {
var $nextElement = element.next();
if ($nextElement.length) {
$nextElement[0].focus();
$nextElement[0].click();
}
}
}).keyup(function (e) {
if (e.which === 8 && !this.value) {
$(this).prev().focus();
$(this).prev().click();
}
});
And I have the following functions as well (on the controller):
$scope.changeFocus = function (n) {
if (n === 0) {
var id = "new_auth3";
var element = $window.document.getElementById(id);
if (element) {
if (isNaN($scope.operation.authorizationCodeConfirm[2]) || $scope.operation.authorizationCodeConfirm[2] == "")
return;
element.blur();
$scope.oldMCCStr = getMCC($scope.operation.authorizationCodeConfirm);
$('#new_auth1').focus
console.log("esta a ser chamado!");
}
}
};
// checks if the key pressed is a number
var checkInput = function (inputArr) {
angular.forEach(inputArr, function (value, key) {
if (null !== inputArr[key]) {
var compare = parseInt(inputArr[key]);
if (isNaN(compare)) {
inputArr[key] = '';
}
}
});
};
$scope.$watch('operation.authorizationCodeConfirm', function (newValue, oldValue) {
checkInput($scope.operation.authorizationCodeConfirm);
console.log("esta a ser chamado!");
}, true);
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am building an app with Cordova, for both of iOS and Android.
I have a page where I have 3 inputs, each input, will take 1 digit to make a code.
Something like: 123
So in the first input you would type '1', it would jump to the next input and focus on it, so you could type the '2'.
This behaviour works fine in Android!
Same code doesn't seem to work for iOS though.
I have the following html:
<form class="matrixZone">
<div class="CardList optionMenu fullRowInput">
<input class="mb20" type="tel" id="new_auth1" move-next-input ng-model="operation.authorizationCodeConfirm[0]" ng-click="newCodeAutorizationfocus(1)" ng-change="changeFocus(2)" maxlength="1" style="-webkit-text-security: disc; text-security: disc;">
<input class="mb20" type="tel" id="new_auth2" move-next-input ng-model="operation.authorizationCodeConfirm[1]" ng-click="newCodeAutorizationfocus(2)" ng-change="changeFocus(3)" maxlength="1" style="-webkit-text-security: disc; text-security: disc;">
<input class="mb20" type="tel" id="new_auth3" move-next-input ng-model="operation.authorizationCodeConfirm[2]" ng-click="newCodeAutorizationfocus(3)" ng-change="changeFocus(4)" maxlength="1" style="-webkit-text-security: disc; text-security: disc;">
</div>
</form>
For the directive move-next-input I have:
function moveNextInput() {
return {
restrict: 'A',
link: function ($scope, element) {
element.on("input", function (e) {
if (element.val().length == element.attr("maxlength")) {
var $nextElement = element.next();
if ($nextElement.length) {
$nextElement[0].focus();
$nextElement[0].click();
}
}
}).keyup(function (e) {
if (e.which === 8 && !this.value) {
$(this).prev().focus();
$(this).prev().click();
}
});
And I have the following functions as well (on the controller):
$scope.changeFocus = function (n) {
if (n === 0) {
var id = "new_auth3";
var element = $window.document.getElementById(id);
if (element) {
if (isNaN($scope.operation.authorizationCodeConfirm[2]) || $scope.operation.authorizationCodeConfirm[2] == "")
return;
element.blur();
$scope.oldMCCStr = getMCC($scope.operation.authorizationCodeConfirm);
$('#new_auth1').focus
console.log("esta a ser chamado!");
}
}
};
// checks if the key pressed is a number
var checkInput = function (inputArr) {
angular.forEach(inputArr, function (value, key) {
if (null !== inputArr[key]) {
var compare = parseInt(inputArr[key]);
if (isNaN(compare)) {
inputArr[key] = '';
}
}
});
};
$scope.$watch('operation.authorizationCodeConfirm', function (newValue, oldValue) {
checkInput($scope.operation.authorizationCodeConfirm);
console.log("esta a ser chamado!");
}, true);
I am building an app with Cordova, for both of iOS and Android.
I have a page where I have 3 inputs, each input, will take 1 digit to make a code.
Something like: 123
So in the first input you would type '1', it would jump to the next input and focus on it, so you could type the '2'.
This behaviour works fine in Android!
Same code doesn't seem to work for iOS though.
I have the following html:
<form class="matrixZone">
<div class="CardList optionMenu fullRowInput">
<input class="mb20" type="tel" id="new_auth1" move-next-input ng-model="operation.authorizationCodeConfirm[0]" ng-click="newCodeAutorizationfocus(1)" ng-change="changeFocus(2)" maxlength="1" style="-webkit-text-security: disc; text-security: disc;">
<input class="mb20" type="tel" id="new_auth2" move-next-input ng-model="operation.authorizationCodeConfirm[1]" ng-click="newCodeAutorizationfocus(2)" ng-change="changeFocus(3)" maxlength="1" style="-webkit-text-security: disc; text-security: disc;">
<input class="mb20" type="tel" id="new_auth3" move-next-input ng-model="operation.authorizationCodeConfirm[2]" ng-click="newCodeAutorizationfocus(3)" ng-change="changeFocus(4)" maxlength="1" style="-webkit-text-security: disc; text-security: disc;">
</div>
</form>
For the directive move-next-input I have:
function moveNextInput() {
return {
restrict: 'A',
link: function ($scope, element) {
element.on("input", function (e) {
if (element.val().length == element.attr("maxlength")) {
var $nextElement = element.next();
if ($nextElement.length) {
$nextElement[0].focus();
$nextElement[0].click();
}
}
}).keyup(function (e) {
if (e.which === 8 && !this.value) {
$(this).prev().focus();
$(this).prev().click();
}
});
And I have the following functions as well (on the controller):
$scope.changeFocus = function (n) {
if (n === 0) {
var id = "new_auth3";
var element = $window.document.getElementById(id);
if (element) {
if (isNaN($scope.operation.authorizationCodeConfirm[2]) || $scope.operation.authorizationCodeConfirm[2] == "")
return;
element.blur();
$scope.oldMCCStr = getMCC($scope.operation.authorizationCodeConfirm);
$('#new_auth1').focus
console.log("esta a ser chamado!");
}
}
};
// checks if the key pressed is a number
var checkInput = function (inputArr) {
angular.forEach(inputArr, function (value, key) {
if (null !== inputArr[key]) {
var compare = parseInt(inputArr[key]);
if (isNaN(compare)) {
inputArr[key] = '';
}
}
});
};
$scope.$watch('operation.authorizationCodeConfirm', function (newValue, oldValue) {
checkInput($scope.operation.authorizationCodeConfirm);
console.log("esta a ser chamado!");
}, true);
edited Nov 8 at 6:10
FishSaidNo
3015
3015
asked Nov 7 at 18:38
Ana Sequeira
77110
77110
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53195729%2fauto-input-focusing-not-working-in-ios-works-in-android-with-cordova%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown