...

View Full Version : Form onSubmit alert()



svoltmer
08-12-2008, 07:01 PM
I have a form that onSubmit processes using "formMail". I would like to also have it display an "alert('Form Submitted - Thank You") onSubmit as well. I have tried all kinds of methods, but nothing is working. Any suggestions? Thanks!

Link: http://www.crosst.org/saved.html

Philip M
08-12-2008, 07:33 PM
At the end of whatever validation you have:-

alert ("Form submitted - Thank you!");
return true;
}

Note the position of the quotation marks. And both must be either single or double quotes, but not one of each.


Your form appears to have no validation at present. Change this line to:-

<input name="submit" type="submit" class="submit" id="submit" value="Submit" onclick = "return showMessage()" />

<script type = "text/javascript">
function showMessage() {
alert ("Form submitted - Thank you!");
return true;
}
</script>

Also note that in Internet Explorer, names and IDs are global variables and thus you should NEVER use a global variable or function name which is the same as an element name or ID. You should also avoid giving names to your variables/functions/arguments words which are JavaScript methods/attributes such as 'name' or 'id' or 'value' or 'checked' or 'submit' or 'replace' or 'parseInt'.






Quizmaster: Which surname was shared by a historical outlaw called "Butch" and a fictional cowboy called "Hopalong"?
Contestant: Lesbian.

svoltmer
08-14-2008, 06:11 PM
Thanks!

That was it. I don't know why I didn't have any action on the input for the submit. I appreciate your help. Have a blessed day!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum