Navigation

Jquery: Capitalize the First Letter of String Using Jquery

capitalize first letter javascript, capitalize first letter jquery, capitalize first letter using jquery

Introduction

Today, I am explaining one more working example of Jquery. I have explained how we can capitalize first letter of string using Jquery. It is very common requirements while we are typing sentence in input box. I have used JSfiddle to run here fully working example of Jquery.
Jquery Capitalize First Letter


Step 1: Taking Two Input Box (First Name & Last Name) 

First step taking two input boxes to illustrate the example with all functionality.

First Name: Last Name:

Step 2: Writing Jquery Kepypress Event to Capitalize First Letter 

Now writing Jquery code to Capitalize first letter of string using Jquery

  $("#txtFirstName").keypress(function () {
      var _val = $("#txtFirstName").val();
      var _txt = _val.charAt(0).toUpperCase() + _val.slice(1);
      $("#txtFirstName").val(_txt);
  })

   $("#txtLastName").keypress(function () {
      var _val = $("#txtLastName").val();
      var _txt = _val.charAt(0).toUpperCase() + _val.slice(1);
      $("#txtLastName").val(_txt);
  })

Complete Working Example to Capitlize first letter of String

Conclusion

I have explained all important steps to capitalize first letter of string using Jquery. Jsfiddle used to run example real time online. If anyone need more help, then let me know.

Relevant Reading

Share

Anjan Kant

Outstanding journey in Microsoft Technologies (ASP.Net, C#, SQL Programming, WPF, Silverlight, WCF etc.), client side technologies AngularJS, KnockoutJS, Javascript, Ajax Calls, Json and Hybrid apps etc. I love to devote free time in writing, blogging, social networking and adventurous life

Post A Comment:

0 comments: