Convert values entered into inputs according to language selection

38 views Asked by At

I have a button to select 3 languages. I want to convert the symbols entered in the inputs according to this language selection. If currentCulture==fi-us or fi-ru, even if a value is entered with a dot in the input, this should be converted to a comma. If currentCulture==fi-tr, even if a value is entered with a comma in the input, this comma should be converted to a dot.

 document.querySelectorAll('.form-control').forEach(function(input) {
        input.addEventListener('input', function(event) {
            let value = event.target.value;
            let currentCulture = document.querySelector('.nav-link.dropdown-toggle i').classList[1];
            console.log("User-selected language: " + userCulture);
            if (!isNaN(value) && value.includes('.')) {
                let parts = value.split('.');
                if (parts[1].length > 2) {
                    parts[1] = parts[1].slice(0, 2);
                    event.target.value = parts.join('.');
                }
            }
        });
    });```


How can these conversions be performed according to the language choice?
0

There are 0 answers