Simple JavaScript Problem...

N

number1.email

Hello,

I have a simple Web Page Questionairre in which questions are read from
a database, and the user can indicate the correct answer via either a
radio input control or a dropdown list.

The number of questions that is displayed on the screen can
vary...depending on the number of questions that satisfy certain
criteria.

Does anyone have any sample code, or can show me how I can validate
this Web Page in JavaScript so that the user is forced to "answer"
every question on the form (whether it is a radio control or dropdown
list).

Thanks.
 
A

Adrienne Boswell

Gazing into my crystal ball I observed (e-mail address removed) writing in
Hello,

I have a simple Web Page Questionairre in which questions are read from
a database, and the user can indicate the correct answer via either a
radio input control or a dropdown list.

The number of questions that is displayed on the screen can
vary...depending on the number of questions that satisfy certain
criteria.

Does anyone have any sample code, or can show me how I can validate
this Web Page in JavaScript so that the user is forced to "answer"
every question on the form (whether it is a radio control or dropdown
list).

Thanks.

Not a good idea to rely on client side script to validate a form. Final
validation should be done server side. Yes, you can do client side
validation for the user's convience, but make sure that you always check on
the server.

As to your original question, Google is your friend
<http://www.google.com/search?
client=opera&rls=en&q=javascript+form+validation&ie=utf-8&oe=utf-8>
 
M

Malte

Hello,

I have a simple Web Page Questionairre in which questions are read from
a database, and the user can indicate the correct answer via either a
radio input control or a dropdown list.

The number of questions that is displayed on the screen can
vary...depending on the number of questions that satisfy certain
criteria.

Does anyone have any sample code, or can show me how I can validate
this Web Page in JavaScript so that the user is forced to "answer"
every question on the form (whether it is a radio control or dropdown
list).

Thanks.

I am currently writing pages that require approx. 600 lines of
javascript in addition to the 3-400 lines of struts/html.

To do what you want you will have to have your submit call a validate()
js function which implements the userside logic you want. Obviously, you
will have to implement serverside checking as well, or risk db
inconsistency.

Any js primer will tell you how to get/set element values and how to use
the sick (My Opinion) language.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,078
Latest member
MakersCBDBlood

Latest Threads

Top