Concatenating two input fields into one hidden field and passing on form submit
I got a request to send full-name when a form is submitted. The form gathers first-name and last-name and I just need to concatenate them and submit it in a hidden form field. Here's what I have so far for something that should be simple, but I'm missing something here:
- <input name="firstName" id="firstName" type="text">
- <input name="lastName" id="lastName" type="text">
- <input name="fullName" id="fullName" value="" type="hidden">
- $("#new-user").submit(function(event){
- var fName = firstName.val();
- var lName = lastName.val();
- $('#fullName').val(fName + ' ' + lName);
- });