My input field allows only characters, no digits. I want when I type that the first character is in caps and small follows and anywhere is space do same, caps and small follows, and only one space should be allowed in the input field.
$(function() {
$('#txttName').keydown(function(e) {
if (e.shiftKey || e.ctrlKey || e.altKey) {
e.preventDefault();
} else {
var key = e.keyCode;
if (!((key == 8) || (key == 32) || (key == 46) || (key >= 35 && key <= 40) || (key >= 65 && key <= 90))) {
e.preventDefault();
}
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<p>Name</p>
<input id="txttName" value="">