Javascript - Convert String To Uppercase and Lowercase

In this tutorial we will create a Convert String To Uppercase and Lowercase using Javascript. JavaScript is a scripting or programming language that allows you to implement complex things on web pages. It can renders web pages in an interactive and dynamic fashion. It is widely used in designing a stunning website. This code can be used as your converter to your mathematical problem. So Let's do the coding...

Getting Started:

The Main Interface

This code contains the interface of the application. This code will render application and display the form. To create this just write these block of code inside the text editor and save this as index.html.

Creating the Script

This code contains the script of the application. This code will change the string format when clicked. To do this just copy write the code as shown below inside the text editor and save it as script.js.

var string = document.getElementById("string");

function UpperCase(){

if(GetRadio()=="all"){

string.value= string.value.toUpperCase();

}elseif(GetRadio()=="first"){

string.value= UpperCaseFirstLetter(string.value);

}

}

function LowerCase(){

if(GetRadio()=="all"){

string.value= string.value.toLowerCase();

}elseif(GetRadio()=="first"){

string.value= LowerCaseFirstLetter(string.value);

}

}

function GetRadio(){

for(var i =0; i < document.getElementsByName('status').length; i++){

if(document.getElementsByName('status')[i].checked)

{

return document.getElementsByName('status')[i].value;

}

}

}

function UpperCaseFirstLetter(string){

return string[0].toUpperCase()+ string.slice(1);

}

function LowerCaseFirstLetter(string){

return string[0].toLowerCase()+ string.slice(1);

}

There you have it we successfully created a Convert String To Uppercase and Lowercase using javascript. I hope that this very simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!