Quantcast
Channel: .Net Core | MVC | HTML Agility Pack | SQL | Technology Crowds
Viewing all articles
Browse latest Browse all 544

Jquery: Capitalize the First Letter of String Using Jquery

$
0
0

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


Viewing all articles
Browse latest Browse all 544

Trending Articles