On Submit show Alert Box

I'm trying to figure out how when I hit the submit button I can have a box pop up that says

"Thanks for giving your opinion"

I tried the below code, but not working.

<form action="submitsurvey.php" onsubmit="alert('Thanks for giving your opinion');" enctype="multipart/form-data" method="post">
									<div class="radio">
										<input name="option" type="radio" class="off" value="'.$row3['id'].'"/>
										<a class="custom"></a>
									<div class="text">
										<label for="option" style="word-wrap:break-word;width:300px;">'.$row3['answer'].'</label>
<input type="submit" class="btn blue" value="SUBMIT">

Open in new window

LVL 12
Nathan RileyFounderAsked:
Who is Participating?
Ray PaseurConnect With a Mentor Commented:
<form action="submitsurvey.php" enctype="multipart/form-data" method="post">
<input type="submit" class="btn blue" value="SUBMIT" onClick="alert('Thanks for giving your opinion');">

Open in new window

smeghammerConnect With a Mentor Commented:
If you want full control over the submission, change the button type from SUBMIT to BUTTON, and add an onclick hander that calls a function:

function submitForm()
  //perhaps some client validation here
  alert("Thanks for submitting.")
<input type="button" onclick="submitForm();" name="go" value="Go" />

Open in new window

In reality, you probably want to do validation and checking for successful form submission on the server, as a 'thank you' message should only be presented if the form was actually submitted correctly.
jjkkj jknykykCommented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.