Below is a form I'm using on my website but I don't like that it takes you to a different page to show you what you have submitted but when you click on the back arrow on the browser, the values are still in the boxes and you can't clear them by refreshing the browser. You have to actually go to another page and come back to the form before it's cleared.
You're not really missing anything. Browsers do this as a convenience for users. You could add a <input type="reset" value="Reset Form"> button to let users clear the form manually.
What if I wanted the customer be re-routed to the home page when they click submit on the form? What code can I use for that? Thanks for your help with this.
What if I wanted the customer be re-routed to the home page when they click submit on the form? What code can I use for that? Thanks for your help with this.
if your form submits via javscript/ajax, then you would add a redirect in that code, if your using a simpler setup, for example if the user is always directed to the page that processes the form when they submit, then you can use that page to redirect upon success
code examples woule be dependant on what server side languages you are using now
You can also add a meta redirect on the results page if you need too. I do this alot on websites I build. I will let them see the results they submitted and then have them redirected automatically after 5 secs or so. You can also use Javascript to redirect the form page to any page you want once the submit button is clicked, and have the results page open in a separate window at the same time. If you need the code I can show you. Just let me know.
Here it is anways That will redirect the form page and if you use something like Natemail or something that goes to a review page for the data submitted it will open up in a new window. This was from an old post on here that I answered a while back.
Last edited by PBSWebDesign; 03-22-2012 at 09:14 PM.
----------------------------------------------------------------------------------------------
WYSIWYG editors will never beat my hand written code!!!! Learn to do it in notepad and learn how to actually control your website! Current Project http://www.jmcanineservices.com
<select name="Second_Choice_Class_date">
<option>Choose One</option>
<option>Saturday, April 7, 2012</option>
<option>Saturday, April 14, 2012</option>
<option>Saturday, April 21, 2012</option>
<option>Saturday, April 29, 2012</option>
<option>Saturday, May 5, 2012</option>
<option>Saturday, May 12, 2012</option>
<option>Saturday, May 19, 2012</option>
<option>Saturday, May 26, 2012</option>
<option>Saturday, June 2, 2012</option>
<option>Saturday, June 9, 2012</option>
<option>Saturday, June 16, 2012</option>
<option>Saturday, June 23, 2012</option>
<option>Saturday, June 30, 2012</option>
</select>
Content is where you enter in the amount of seconds until the refresh
----------------------------------------------------------------------------------------------
WYSIWYG editors will never beat my hand written code!!!! Learn to do it in notepad and learn how to actually control your website! Current Project http://www.jmcanineservices.com
Will someone tell me how to make at least the "email address" and the "name" on my form above required fields. I don't want people to just hit the submit button and be able to send that form empty like it is now. I really appreciate that.
This is pretty easy. You can use javascript to handle this. A simple google search will point you to the w3 school for JS validation. I will post what they said here.
To validate the name field:
Code:
function validateForm()
{
var x=document.forms["myForm"]["fname"].value;
if (x==null || x=="")
{
alert("First name must be filled out");
return false;
}
}
function validateForm()
{
var x=document.forms["myForm"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
}
----------------------------------------------------------------------------------------------
WYSIWYG editors will never beat my hand written code!!!! Learn to do it in notepad and learn how to actually control your website! Current Project http://www.jmcanineservices.com
Bookmarks