Exclamation How can I validate my contact form?

ciril tomy

New Member
Messages
53
Reaction score
1
Points
0
Hi Friends!

Can anybody tell me hoe can I validate my contact form using java script?
You can see my contact form http://www.webworld.x10hosting.com/contact.html
is not working properly. I tried to validate it by javascript but it didn't work out...

Please help me....
Thanks in advanse.
__________________
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Well, where you attach your validation code here:

Code:
<input name="email" type="text" class="text" id="email" 
onblur="MM_validateForm('name','','R','email','','RisEmail');
return document.MM_returnValue" />

so the only time the script checks the fields is when you leave the e-mail box.
As long as you stay out of the e-mail box, the code never runs. Even if it does run,it does not keep the user from ignoring it and submitting the form anyway.

If you want the validation to occur when the user tries to submit the form and you want the script to stop the form from being submitted if there are errors, you need to attach your validation script to to the onsubmit event handler of the form itself.

Code:
<form action="contact.php" method="post" 
[B]onSubmit=="MM_validateForm('name','','R','email','','RisEmail');
return document.MM_returnValue"[/B]
enctype="application/x-www-form-urlencoded">

The "return document.MM_returnValue" will keep the form from being submitted if there are errors on the page.

Remember that the user can turn off JS, etc, so you should never trust this type of validation. You have to check the input again in the server script that handles the submission. JS validation helps remind users to properly fill out a form, but it is lousy security.

Note:
remember that 'hidden' fields are not secure.
Code:
<input name="hiddenField" type="hidden" id="hiddenField" value="mailto:ciril_sep17@hotmail.com" />

PS: The highlighting of the input boxes using mouseover is not done well. Highlighting the name input box shifts all the other boxes down and looks amateurish.
 
Last edited:

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
Dreamweaver is a very popular WYSIWYG, but it will never allow you to fine tune your website as much as coding by hand. For the validation, I'd recommend a little JS snippet that will help you add validation to your form. It's called JavaScript Form Validation and it's available at JavaScript-Coder.com.
And for your website, you should, in the menu, change either the color of the mouseover image or the color of the text when the mouse goes over it as it is pretty harsh on the eyes. Oh and your porfolio's images slide in and out a bit too fast. Try adding a little pause between the slide in and out, or make the movement slower.
 
Last edited:
Top