html form validation

first thing is if you're going to put text in the text box, make it so when the focus goes to the box it disappears. if you don't know how to do that then put it outside the box to the side or something.

one thing i have noticed is people seem to think that if you can do one thing on a computer, then you can do anything, and so if you can't make websites correct then they may think you can't fix computers, so imo that should be changed.

you should try learning how to deal with sessions, as when you do you can set a session each time the user submits the form, and if it resubmits within 30 seconds or aybe 20 just to be safe, then say they have to wait.

also you can add a simple question to try to avoid spammers, e.g. 10*5 = ___

have this randomised between a set of questions if you want to try and reduce human spammers also
 
one thing i have noticed is people seem to think that if you can do one thing on a computer, then you can do anything, and so if you can't make websites correct then they may think you can't fix computers, so imo that should be changed.

amen :)

Back on topic, try using a verification image - not a 2 second job, you'll have to make a drink and read ;)

Ther is also another method, that I forget the name of, whereby the form action is hashed E.g.

Code:
<form action="596b18a119ac6362bade717a541a633c">
 
Last edited:
Please re-check the form, i have put some basic javascript validation in that means you have to fill in every field, it also then redirects you to a .html page, then back to the contact page - clearing the form.

Edit: also put onclick, remove the writing in the description box and added * s to fileds.
 
Last edited:
Please re-check the form, i have put some basic javascript validation in that means you have to fill in every field, it also then redirects you to a .html page, then back to the contact page - clearing the form.

Edit: also put onclick, remove the writing in the description box and added * s to fileds.

change it to onfocus as soe users use tab to switch input field, emaing the onclick evet wont have been called and the text will remain.
 
Please re-check the form, i have put some basic javascript validation in that means you have to fill in every field, it also then redirects you to a .html page, then back to the contact page - clearing the form.

Edit: also put onclick, remove the writing in the description box and added * s to fileds.

What server validation do have, as I could easily turn off JavaScript....
 
change it to onfocus as soe users use tab to switch input field, emaing the onclick evet wont have been called and the text will remain.

Thank you, i have now incorporated this.

What server validation do have, as I could easily turn off JavaScript....

Erm, not sure? When the form is submitted; it goes through a .php file which then sends it to my email.
 
In the PHP file you want to do the same tests you are doing in the JavaScript.. i.e.:

PHP:
function validate($name, $phone) {
	if ( strlen($name) < 5 || strlen($phone) < 7 )
		return 0;
	else // all good
		return 1;
}

If the result of validate() is 1 then you're ok to send the email, else display the errors and make the user try again. You would probably actually return an array of errors to show on your page as well.
 
Back
Top Bottom