Concatenating two input fields into one hidden field and passing on form submit

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:

  1. <input name="firstName" id="firstName" type="text">
  2. <input name="lastName" id="lastName" type="text">
  3. <input name="fullName" id="fullName" value="" type="hidden">

  4. $("#new-user").submit(function(event){
  5.       var fName = firstName.val();
  6.       var lName = lastName.val();
  7. $('#fullName').val(fName + ' ' + lName);
  8. });