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
If you think linearly, you might catch what I think the problem is. When you submit the form, it runs a validate function. What happens at the end of this function? Does it return true? If so, you are then giving the go ahead to send the form. You want your alert to happen before all this is done. So maybe add your alert() in at the very top of your validate function.
Or use AJAX. The problem with showing a validation message like this is that it's not genuine because you show it before you know whether or not the operation was successful. This may or may not be a problem. It depends on the site.
<script alnguage="javascript"> function sayHello() { alert("Hello World"); return true; } </script> Code (markup): <form onSubmit="return sayHello()"> some form objects <input type="submit" value="Submit Form"> </form> HTML: this may give you some idea
I still can't get it to work. I have a limitation, I am using the "formMail" script on a shared web host. Something about the formmail.pl validating doesn't seem to allow me to add an additional "onSubmit" to the form. See what I have tried. Any new suggestions would be appreciated. <script alnguage="javascript"> function formSubmit() { alert("Form Submitted - Thank You"); return true; } </script> <form class="salvation" name="Salvation" method="POST" action="/cgi-sys/formmail.pl" onSubmit="formSubmit() && return validate(this)"> I HAVE TRIED THIS TOO: <form class="salvation" name="Salvation" method="POST" action="/cgi-sys/formmail.pl" onSubmit="return validate(this); return formSubmit();">
<form class="salvation" name="Salvation" method="POST" action="/cgi-sys/formmail.pl" onSubmit="return formSubmit();"> As yleiko suggested.
I still need the "formmail.pl" to validate the form data. If i just use the alert() in the function then the data does not go through the formmail.pl script. Help?
Add the alert() call in the onload of the body of the resulting page generated by formmail.pl. You need to modify formmail.pl to do that.
I don't have access to the "formmail.pl" it is in a secure directory on the hosing company's server. I was able however to put a onClick event on the submit input to run the alert function. It's working fine now. Thanks for your input.