<script> document.getElementById("fname").addEventListener("change", myFunction); function myFunction() { var x = document.getElementById("fname"); x.value = x.value.toUpperCase(); } </script>