•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 392,074 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,135 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 3256 | Replies: 1 | Solved
![]() |
•
•
Join Date: Nov 2006
Posts: 23
Reputation:
Rep Power: 2
Solved Threads: 0
Hi,
I'm trying to validate a checkbox in the form and I'm not sure which property to use. At the moment, I have a checkbox called "termsandcond" and I'm trying to write a javascript validation script that checks to see if it is ticked or not.
If anyone knows what properties I be using, or what I'm doing wrong, that would be really helpful.
Thanks in Advance
ForestTech
I'm trying to validate a checkbox in the form and I'm not sure which property to use. At the moment, I have a checkbox called "termsandcond" and I'm trying to write a javascript validation script that checks to see if it is ticked or not.
function validate(){
var form = document.forms.bookingform;
if(form.elements.termsandcond.value = false){
alert('You must agree to the Terms And Conditions before booking.');
return false;
}
return true;
}If anyone knows what properties I be using, or what I'm doing wrong, that would be really helpful.
Thanks in Advance
ForestTech
Last edited by ForestTech : Nov 27th, 2006 at 6:31 pm.
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 936
Reputation:
Rep Power: 5
Solved Threads: 47
i think the property you're looking for is 'checked'..
I don't know whether forms.elements.xxx will give you a named object handle in return...
if your input is set up: <input name="termsandconds" type="check"/>, you should be able to access it as bookingform.termsandconds.
EDIT: I imagine both methods work though (document.forms.bookingform.elements.termsandconds | bookingform.termsandconds)
I don't know whether forms.elements.xxx will give you a named object handle in return...
if your input is set up: <input name="termsandconds" type="check"/>, you should be able to access it as bookingform.termsandconds.
EDIT: I imagine both methods work though (document.forms.bookingform.elements.termsandconds | bookingform.termsandconds)
Last edited by MattEvans : Nov 27th, 2006 at 6:59 pm.
If it only works in Internet Explorer; it doesn't work.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- Access Date & Time Validation Question (MS Access and FileMaker Pro)
- simple checkbox form array help! (PHP)
- simple solution? Parsing question (C++)
- Help with PHP and checkboxes (PHP)
- How to Embed CheckList Box on HTML Page using Java Script (HTML and CSS)
- Question about fan speed (Cases, Fans and Power Supplies)
- how to validate checkbox with different names? (HTML and CSS)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: this. method is working "backwards"
- Next Thread: Expandable html?


Linear Mode