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.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); })
Post A Comment:
0 comments: