jamesson,
без Ё
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
<script>
window.addEventListener("DOMContentLoaded", function() {
var form = document.querySelector("form"),
input = form.querySelector("#w"),
result = document.querySelector("#result");
function sum(out, el) {
var num = "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ".indexOf(el.toUpperCase());
num != -1 && (num %= 9)
return out + ++num
}
form.addEventListener("input", function(event) {
var res = input.value.split("").reduce(sum, 0);
result.innerHTML = res
})
});
</script>
</head>
<body>
<form>
<input id="w" value="И" type="text">
<br>
</form>
<div id="result"></div>
</body>
</html>
|