I have a javascript in there already that checks if the required fields are filled when you click submit and if they are not there is a pop up that says these fields are not filled in.
When i fill them all in and click submit it works great but it takes me to like cgi-bin/cgimail page that says something like "Success etc....." but i want to change this to lets say a confirmation page on my web site.
Now i ran into a problem, my java code says when submit is hit to validate the fields and when i tried to use this code below a onClick="jump()" in the submit tags on the bottom of my form, it would take me to another page everytime even when all the fields are empty and i press submit, it will pop up and say these fields are not filled in, but then the page would change and i dont want that.
Can anyone help me since im pretty new with java and all i want is, when i click the submit and pop up comes up not to go to another page, but remaiin on the form, And Finally when all the required fields are typed in and customer clicks Submit again, if everything is fine, THEN go to another page and email would be sent to me.
The script is below....
One question is if i add like if/then statement (ex. if function validation() is true then location.href="thankyou.html"??? How would i write this code and where would i put it?
Expand|Select|Wrap|Line Numbers
- <script type="text/javascript">
- <!--
- function validate() {
- with (document.form1) {
- var alertMessage = "The following REQUIRED fields\nhave been left empty:\n";
- if (name.value == "") {
- alertMessage += "\nName" }
- if (address.value == "") {
- alertMessage += "\nAddress" }
- if (city.value == "") {
- alertMessage += "\nCity" }
- if (state.value == "") {
- alertMessage += "\nState" }
- if (zip.value == "") {
- alertMessage += "\nZip Code" }
- if (county.value == "") {
- alertMessage += "\nCounty" }
- if (email.value == "") {
- alertMessage += "\nEmail" }
- if (pricerange.value == "") {
- alertMessage += "\nPlease enter your price range" }
- if (alertMessage != "The following REQUIRED fields\nhave been left empty:\n") {
- alert(alertMessage);
- return (false);
- }
- return (true);
- }
- }
- // -->
- </script>
- <form action="cgi-bin/cgiemail" method="post" onsubmit="return validate()" form
- name="form1">
thanks
slavisa