DeveloperBarn Forums

Go Back   DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Discuss "checkbox validation" in the JavaScript Programming forum.

JavaScript Programming - Javascript is a cross-browser client-side scripting language. Discuss Javascript and AJAX related scripts here.


Reply « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old June 18th, 2008, 03:14 PM
Contributing Member

 
Join Date: Mar 2008
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default checkbox validation

719-572-9400
719-638-3545


hi,

I have a group of checkboxes like this
Code:
<input type="checkbox" name="chk12" id="chk12" value="Yes">Quote 12
<input type="checkbox" name="chk11" id="chk11" value="Yes">Quote 11
<input type="checkbox" name="chk10" id="chk10" value="Yes">Quote 10
<input type="checkbox" name="chk9" id="chk9" value="Yes">Quote 9
<input type="checkbox" name="chk8" id="chk8" value="Yes">Other

<input type="textbox" name="chk8othertext" id="chk8othertext" value="">
If the user doesnt select one of them then i want to fire an alert

if the user selects Other checkbox and doesnt enter a value in the other textbox then fire an alert

here is my code

Code:
if (document.frm1.chk12.checked == false && document.frm1.chk11.checked == false && document.frm1.chk10.checked == false && document.frm1.chk9.checked == false && document.frm1.chk8.checked == false )
		{
		alert ('You didn\'t choose any of the checkboxes!');
		return false;
		}
	else
		{
		return true;
		}

If(document.frm1.chk8.checked ==true)
	{
		if(document.frm1.chk8othertext.value =="")
			{
			alert("enter a value");
			}
	}
but the code is not working

any idea

todd
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old June 18th, 2008, 03:24 PM
Wolffy's Avatar
Slaprentice of Wolves


 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 146
Thanks: 1
Thanked 23 Times in 20 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

You never get to your second IF statement. Remove the else clause of hte first IF.
__________________
Wolffy
------------------------
Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.
Reply With Quote
The Following User Says Thank You to Wolffy For This Useful Post:
richyrich (June 19th, 2008)
  #3 (permalink)  
Old June 18th, 2008, 03:24 PM
mehere's Avatar
Mistress of Sarcasm

 
Join Date: Mar 2008
Location: Wide Awake In Dreamland
Posts: 111
Thanks: 8
Thanked 19 Times in 17 Posts
Rep Power: 1
mehere is on a distinguished road

Awards Showcase
Microsoft SQL Server Classic ASP 
Total Awards: 2

Default

what do you mean not working? are you getting an error message?
__________________
Quote of the Month:
Strife: As long as we have each other, we'll never run out of problems.

Questions to Ponder:
Should vegetarians eat animal crackers?

iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
copyright © 2008 sbenj69
Reply With Quote
  #4 (permalink)  
Old June 18th, 2008, 07:22 PM
don94403's Avatar
Moderator


 
Join Date: Mar 2008
Location: San Mateo, CA, USA
Posts: 43
Thanks: 2
Thanked 3 Times in 3 Posts
Blog Entries: 2
Rep Power: 1
don94403 is on a distinguished road

Awards Showcase
PHP Microsoft Access 
Total Awards: 2

Default

Assuming that your code is in some Event Procedure, Wolffy is right. The way you have it, the first If statement either returns True or False, but in either case it returns, which means bye-bye, it's done.
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Bookmarks

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
display problem checkbox todd2006 JavaScript Programming 4 May 30th, 2008 03:58 PM
Programmatically Add Item to Validation Summary jmurrayhead .Net 0 March 20th, 2008 09:41 AM


Sponsored Links

ASP.NET Resource Index
a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer.

Free Web Directory
Including Chats and Forums Resources, Offer automatic, instant and free directory submissions.
URLZ Web Directory
URLZ Web Directory

Free Web Directory - Add Your Link
The Little Web Directory
Free Web Directory
Pegasus free web directory is a free directory organised by categories.

Web Directory & SEO Services
dirroot web directory


All times are GMT -4. The time now is 07:43 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 2008 DeveloperBarn.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46