platedz,
Вариант ...
<!DOCTYPE HTML>
<html>
<body>
<div contenteditable onkeyup = "test(this)">0123456789</div>
<script>
function getCaretPos(element) {
element.focus();
if (document.selection) {
var sel = document.selection.createRange();
var clone = sel.duplicate();
sel.collapse(true);
clone.moveToElementText(element);
clone.setEndPoint('EndToEnd', sel);
return clone.text.length;
} else {
return window.getSelection().getRangeAt(0).startOffset;
}
return 0;
}
function test(element) {
var x = getCaretPos(element);
var re = /([A-Za-z])/g;
var str = element.childNodes[0].data
if (str.search(re) > 0) x = str.search(re);
str = str.toLocaleLowerCase().replace(re, '');
element.childNodes[0].data = str;
if (document.selection) { //
var range = document.body.createTextRange();
range.moveToElementText(element);
range.collapse(true);
range.moveStart('character', x)
range.select();
} else {
var range = document.createRange();
range.setStart(element.childNodes[0], x);
range.collapse(true);
var sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
}
element.focus();
};
</script>
</body>
</html>