<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<input type="text" name="user" id="user"/>
<script>
var text=document.querySelector("#user");
text.addEventListener("select",selectHandler);
function selectHandler(e) {
var str=text.value.slice(0,text.selectionStart);
str+=text.value.slice(text.selectionStart,text.selectionEnd).toUpperCase();
str+=text.value.slice(text.selectionEnd);
text.value=str;
}
</script>
</body>
</html>