Applying ui-mask on multiple fields on a form sets focus on the last masked input box automatically
This is a weird issue I came across and I wanted to see if I can do something so it does not set the focus on any particular input box. I have multiple date inputs on a form and I am using ui-mask to set a date mask. Let's say I have 4 input boxes with the mask on them. Once the form renders the focus is set on the 4th (last) input box which has the date mask on it. Is there any place I can disable that?
Any news about this ? I got the same issue.
No, I found no resolution to this. So I am just going to let it be for now.
+1 happens in IE11
I have a similar issue where the UI-Masked field in my form is being focused automatically. This only happens in IE.
Same issue here!
Same issue here :(
Same happens to me IE 10 and IE 11
I fixed this issue by changing the source code in the following manner. I don't have time at the moment if nobody fixes it by then, I will send a pull request:
function getCaretPosition(input){
if (!input) return 0;
if (input.selectionStart !== undefined) {
return input.selectionStart;
} else if (document.selection) {
if ($(input).is(':focus')) {
// Curse you IE
input.focus();
var selection = document.selection.createRange();
selection.moveStart('character', input.value ? -input.value.length : 0);
return selection.text.length;
}
return 0;
}
return 0;
}
function setCaretPosition(input, pos){
if (!input) return 0;
if (input.offsetWidth === 0 || input.offsetHeight === 0) {
return; // Input's hidden
}
if (input.setSelectionRange) {
if ($(input).is(':focus')) {
input.focus();
input.setSelectionRange(pos, pos);
}
}
else if (input.createTextRange) {
// Curse you IE
if ($(input).is(':focus')) {
var range = input.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
}
I am having this same problem. Please send that pull request :)
I am having this is problem too. I tested this fix Applying ui-mask on multiple fields on a form sets focus … on IE 11. Fix is working OK.
closed by #415
This fix does not work on Chrome it randomly lose focus while typing. Maybe if you have another directive attached with ui-mask.