How to do printing in upper case only the letter "a"?

Hi friends, there is a problem in just learning js so commonplace things do not know...
there is input, I am entering text and need the text entered appear immediately in the div-e below(this out like) But you need to if input got the letter a, then div it is transferred already in upper case, not pomote?)
my_keyup function() {
 txt = document.getElementById('value_for_div3').value;
 document.getElementById("div3").innerHTML = txt;


//Printed symbol
 my_keypress function($event)

//Key code
 var x = ($event.the keyCode || $event.which);
 var x_char = String.fromCharCode(x);

 //If the letter a(Russian)
 if (x_char=='a') {


June 7th 19 at 14:46
1 answer
June 7th 19 at 14:48
There is an easier way:
var div = document.getElementById("div3");
var input = document.getElementById('value_for_div3');

input.addEventListener('keyup', function(e) {
 div.innerHTML = this.value.replace(/a/g, 'A');

In this example, with "a" from the Cyrillic alphabet.

If you want to replace and from Cyrillic and Latin, then the regular expression replace:
div.innerHTML = this.value.replace(/(a|a)/g, '$1'.toUpperCase());

The symbols on the same form, but the codes are different.

Thank you very much!) What you need!) - Gretchen_Daniel commented on June 7th 19 at 14:51
So why two different letters for one to replace? :)
You can write this.value.replace(/(a|a)/g, '$1'.toUpperCase()); - Dolores40 commented on June 7th 19 at 14:54
I haven't thought of. Added in response. Thank you! - Lenny.Botsfo commented on June 7th 19 at 14:57
, the brackets of my version of missed, but without them $1 not will be casted. - Dolores40 commented on June 7th 19 at 15:00

Find more questions by tags JavaScript