I figured out the solution using the additional settings of contact form 7 and placing the following code in these settings.
Note: it only works for Ajax based forms.
on_sent_ok: "var name = $('.wpcf7 input[name=your-name]').val();var email = $('.wpcf7 input[name=your-email]').val();$('.wpcf7').hide();$('.entry-title').html('Thank you');$('.entry-content').html('thank you '+name+' : someone from our office will get in touch with you via '+email+' within 24 hours.');"
Open the contact form configuration page and paste the code above as shown below:

Output Example:

source share