Add confirmation notification after submit in civicrm form in Wordpress
Welcome to StackExchange!
It might help with answers if you clarified the purpose of the form. What will you then do with the collected Name and email?

It looks like the way you are attempting will require JS so maybe we should look at other options.


Depending on what you need the information for, you could use a Civi Membership or Event form, these would give you built in responses or redirection. You can create a profile that just uses Name and email and set the event/membership to No Fee.
Check out Caldera Forms or Gravity Forms. Both have CiviCRM integrations. I have used them both in the past. And both will give you the ability to create your own response or redirect.