JavaScript - testing for a checked checkbox?
#1
I have a form which cannot be submitted until the user checks an 'agree' box:
<INPUT id="checkAgree" type="checkbox" name="checkAgree" value="agree">
In my JS validation I have:
if (document.frmProcessreg.checkAgree.checked)
{
alert("Please confirm you have read and agree to the terms and conditions.");
}
Obviously this is doing the opposite of what I want, bringing up the alert if the box is checked, not unchecked. I've tried "if (document.frmProcessreg.checkAgree.value != 'agree') but that doesn't want to work. Neither does "if not (document... etc".
Any suggestions?
Thanks!
<INPUT id="checkAgree" type="checkbox" name="checkAgree" value="agree">
In my JS validation I have:
if (document.frmProcessreg.checkAgree.checked)
{
alert("Please confirm you have read and agree to the terms and conditions.");
}
Obviously this is doing the opposite of what I want, bringing up the alert if the box is checked, not unchecked. I've tried "if (document.frmProcessreg.checkAgree.value != 'agree') but that doesn't want to work. Neither does "if not (document... etc".
Any suggestions?
Thanks!
#3
Sorted thanks!
Sooo simple as well. Clearly too easy for you so....
I have a registration form here:
http://www.crewise.com/earnwise/registration.asp
At the section for Qualifications / Skills there are three colums and three rows, to enable three qualifications to be entered.
What I need to do is initially show one row, with a button to add more, so that the user can enter as many or as few qualifications as they need to.
I've done something like this before, dynamically building tables, but that was with code a collegue wrote.
What I've tried so far is this:
----------------------
var theHTML
theHTML = "<TR><TD>test</TD></TR>"
function addRow()
{
theHTML = theHTML + "<TR><TD>test</TD></TR>"
}
----------------------
then a link to run addRow();
As I expected, this doesn't update the page and reloading it will reset all the fields on the form. I think it may be done with a span or a div container.
Should have took a copy of the code when I had the chance!
Thanks!
Sooo simple as well. Clearly too easy for you so....
I have a registration form here:
http://www.crewise.com/earnwise/registration.asp
At the section for Qualifications / Skills there are three colums and three rows, to enable three qualifications to be entered.
What I need to do is initially show one row, with a button to add more, so that the user can enter as many or as few qualifications as they need to.
I've done something like this before, dynamically building tables, but that was with code a collegue wrote.
What I've tried so far is this:
----------------------
var theHTML
theHTML = "<TR><TD>test</TD></TR>"
function addRow()
{
theHTML = theHTML + "<TR><TD>test</TD></TR>"
}
----------------------
then a link to run addRow();
As I expected, this doesn't update the page and reloading it will reset all the fields on the form. I think it may be done with a span or a div container.
Should have took a copy of the code when I had the chance!
Thanks!
#4
Overkill for what you want, but you could see what's being done in this example and take it from there: http://www.mattkruse.com/javascript/...mentation.html
Just another point: you should check your checked flag on the server side too, as people can and do turn off Javascript, or create their own submit page, or ... Never rely on client side authentication.
Just another point: you should check your checked flag on the server side too, as people can and do turn off Javascript, or create their own submit page, or ... Never rely on client side authentication.
#5
Thread
Thread Starter
Forum
Replies
Last Post