

function sel(start, end) {
	if (this.nodeName === "INPUT" || this.nodeName === "TEXTAREA"){
		var inputStart = Math.min(start || 0, this.value.length);
		var inputEnd = Math.min(
			Math.max(end || this.value.length, inputStart),
			this.value.length);
		if (this.setSelectionRange) {
			this.focus();
			this.setSelectionRange(inputStart , inputEnd);
		} else if (this.createTextRange) {
			var range = this.createTextRange();
			range.collapse(true);
			range.moveEnd('character', inputEnd);
			range.moveStart('character', inputStart);
			range.select();
		}
	}
}


function createSelection(field, start, end) {
	if( field.createTextRange ) {
		var selRange = field.createTextRange();
		selRange.collapse(true);
		selRange.moveStart('character', start);
		selRange.moveEnd('character', end - start);
		selRange.select();
		field.focus();
	} else if( field.setSelectionRange ) {
		field.focus();
		field.setSelectionRange(start, end);
	} else if( "selectionStart" in field ) {
		field.selectionStart = start;
		field.selectionEnd = end;
		field.focus();
	}
}

var el = El("textarea").to(document.body.empty())
el.value = "12.34.56"
el.on("click", function(){
	sel.call(el, 3, 5)
})


