html question (check box)

L

lrbtav

Hi, I have a site with a built in 'contact us' form; how can I force
the user to check a certain check box before allowing them to submit
the form? This site is hosted on an ASP enabled godaddy server, but I
figured there was some html or js function that would accomplish this.
Thanks
 
N

Nico Schuyt

Hi, I have a site with a built in 'contact us' form; how can I force
the user to check a certain check box before allowing them to submit
the form? This site is hosted on an ASP enabled godaddy server, but I
figured there was some html or js function that would accomplish this.

HTML: impossible
JS: unreliable
Handle it in ASP after the form is submitted
 
R

Rik

Nico said:
HTML: impossible
JS: unreliable
Handle it in ASP after the form is submitted

Well, TRY to handle it with JS, but make sure of it on the server. It saves
a lot users an unneccessary trip to the server, get the contents, load the
page, just to get the error that he forgot to check a box after.
 
T

tcremer

In the form tag add an onsubmit which calls a JavaScript function to
check whether your checkbox is actually checked. If it isn't return
false with a message of some kind. If it is checked, return true and
then (as others have said) check via ASP to ensure the box was checked.

Easy enough.. :)
 
N

Nico Schuyt

Well, TRY to handle it with JS, but make sure of it on the server.
It saves a lot users an unneccessary trip to the server, ...

But makes things unneccessary complex due to the double validation :)
 
L

lrbtav

To use a JS function, would something like this work:

function checkscript() {
if (window.document.form.BoxChecked.checked=false) {
alert('Warning: Please agree to our terms of service.');
return false;
}
else if (window.document.form.BoxChecked.checked=true) {
alert('Thank you for your business!');
return true;
}

? thanks
 

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,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top