Javascript DOM HTML Input Radio convert text in an input field to uppercase

Introduction

Use a radio button to convert text in an input field to uppercase:

document.getElementById("fname").value = document.getElementById("fname").value.toUpperCase();

View in separate window

<!DOCTYPE html>
<html>
<body>

<form>
  First Name: <input type="text" id="fname" value="CSS">
  Convert to upper case/*from   www . ja  v a2  s.  c om*/
  <input type="radio" onclick="if(this.checked){myFunction()}">
</form>

<script>
function myFunction() {
  document.getElementById("fname").value = document.getElementById("fname").value.toUpperCase();
}
</script>

</body>
</html>



PreviousNext

Related