We help IT Professionals succeed at work.

Concatenate 2 field values in form with jQuery and put the concatenated text in a 3rd field on form.

plord1234
plord1234 asked
on
I would like the code to do the following:

I have a form on a page with fields "first_name" and "last_name".  I wish to concatenate the values entered into the 2 fields into a hidden 3rd field "full_name" on the form submit event.  This must be done with jQuery.
Comment
Watch Question

Web Application Programmer
Commented:
$('#form_id').submit(function(){

	$('#full_name').val( $.trim( $('#first_name').val() + ' ' + $('#last_name').val() ) );
	
});

Open in new window


Note: I assumed you have the ID attribute set to the names you specified.

Author

Commented:
Perfect.