Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-01-2010, 05:58 PM   PM User | #1
factory!
New to the CF scene

 
Join Date: Mar 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
factory! is an unknown quantity at this point
Javascript validation problem

I have an issue with a form I am creating, I have many check boxs where at least one of the 2 needs to be selected and the final one has to be selected for the submit button to become active

Code:
<form id="form1" action="#" method="post">

One <input type="checkbox" name="value1" onMouseDown='submit_form()'/>
Two<input type="checkbox" name="value2" onMouseDown='submit_form()'/>
//atleast 1 of these 2 has to be selected

Three<input type="checkbox" name="value3" onMouseDown='submit_form()'/>
//this 1 has to be selected

<input type="submit" name="submit" value="submit" id="submit" disabled="disabled"/>

this is the javascript I have atm to do this

Code:
function submit_form(){
	if (form1.value1.checked == false || form1.value2.checked == false) {
		document.getElementById(submit);
		orderForm.submit.disabled=false;
	}
}
i cant seem to get this to work, forgetting about the 3rd checkbox for now

any help would be greatly appreciated!
factory! is offline   Reply With Quote
Old 03-01-2010, 07:47 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,035
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
There ain't no such thing as onMouseDown in relation to a checkbox. onclick perhaps?

if (form1.value1.checked == false && form1.value2.checked == false) {
alert ("You must check one of the two checkboxes to proceed");
return false;
}
if (form1.value3.checked == false) {
alert ("You must check box 3 before you can proceed");
return false;
}


It is your responsibility to die() if necessary….. - PHP Manual

Last edited by Philip M; 03-01-2010 at 07:49 PM..
Philip M is online now   Reply With Quote
Old 03-01-2010, 08:09 PM   PM User | #3
factory!
New to the CF scene

 
Join Date: Mar 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
factory! is an unknown quantity at this point
thankyou for that, helped solve the problem!
factory! is offline   Reply With Quote
Reply

Bookmarks

Tags
eventhandlers, form, javascript, validation

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:52 AM.


Advertisement
Log in to turn off these ads.