I am making a form for my project. All input field have the same class assigned. In css file i capitalize every word and that is working just fine.
But when i try to get the value of the field with jQuery .val() the word is not capitalized
var name = $('input[name=name').val();
var lastName = $('input[name=lastName]').val();
console.log(name + " " + lastName);
.MyForm {
text-transform: capitalize;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form><br>
<label>Name</label><input class="MyForm" name="name"><br>
<label>Last Name</label><input class="MyForm" name="lastName"><br>
</form>
In the input field i see John and Smith
and the console prints john smith