I have a javascript code that auto-capitalizes first letter of every sentence as typed in any input field(s) of the page.
The code is as follows:
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$(document).ready(function() {
$('input').on('keydown', function(event) {
if (this.selectionStart == 0 && event.keyCode >= 65 && event.keyCode <= 90 && !(event.shiftKey) && !(event.ctrlKey) && !(event.metaKey) && !(event.altKey)) {
var $t = $(this);
event.preventDefault();
var char = String.fromCharCode(event.keyCode);
$t.val(char + $t.val().slice(this.selectionEnd));
this.setSelectionRange(1,1);
}
});
});
});//]]>
</script>
I need help in transforming the above code to autocapitalize first letter of every word typed in input fields instead of just the first word only.