How can I make input group involves two inputs?
I was not content with any of the answers on this page, so I fiddled with this myself for a bit. I came up with the following
angular.module('showcase', []).controller('Ctrl', function() {
var vm = this;
vm.focusParent = function(event) {
angular.element(event.target).parent().addClass('focus');
};
vm.blurParent = function(event) {
angular.element(event.target).parent().removeClass('focus');
};
});
.input-merge .col-xs-2,
.input-merge .col-xs-4,
.input-merge .col-xs-6 {
padding-left: 0;
padding-right: 0;
}
.input-merge div:first-child .form-control {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.input-merge div:last-child .form-control {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.input-merge div:not(:first-child) {
margin-left: -1px;
}
.input-merge div:not(:first-child):not(:last-child) .form-control {
border-radius: 0;
}
.focus {
z-index: 2;
}
With this it is possible to set the width of the individual inputs to your liking. Also a minor issue with the above snippets was that the input looks incomplete when focussed or when it is not valid. I fixed this with some angular code, but you can just as easily do this with jQuery or native javascript or whatever.
The code adds the class .focus to the containing div's, so it can get a higher z-index then the others when the input is focussed.