DHTML/Form Validation
Expert: Ernesto de Lara - 3/13/2007
QuestionHi Ernesto,
I work with Dreamweaver and have used it's form validation feature which works fine but it a quite limited. What I have is a form that has questions with multichoice answers which are selected by clicking a radio button. On submitting I want the user to be prompted to "try again" on questions they have not answered correctly. ie The form will not be submitted until all the questions are answered correctly. (It's a learning thing more than a test)Is there an easy way to this or do I need some complex programing done?
Thanks
Richard
AnswerHi Richard
Yes, you do need some coding to do that. Hopefully it is not very complex. It is done with javascript. However, you should write this code by yourself since I donīt know how Dreamweaver can help it.
The things works like this: You start trapping the act of submitting the form using the javascript onsubmit event. When this event occurs a validation routine takes places looking for wrong answers from the user. In that case the form is not validated showing the user the need for a "try again" action.
You can find a lot of detail explanations, tutorials and ready to copy code using the words [javascript onsubmit form validation] in your search at google.