Tuesday, September 3, 2013

javascript set to uppercase , Lowerase, Capitalize

Upper case

 <script>
  var str="Hello world!";
  document.write(str.toUpperCase());
</script>

Lower case

 <script>
  var str="Hello world!";
  document.write(str.toLowerCase());
</script>

Capitalize

function toTitleCase(str)
{
    return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}

No comments:

Post a Comment

Complete Authentication System in ASP.NET Core using JWT

JWT (JSON Web Token) authentication is widely used for securing APIs in modern applications. In this article, we will build a complete authe...