+ Reply to Thread
Results 1 to 4 of 4

Thread: checkbox validation

  1. #1
    Barn Loyal todd2006 is an unknown quantity at this point todd2006's Avatar
    Join Date
    Mar 2008
    Posts
    889
    Rep Power
    4

    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

  2. #2
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    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. Void where prohibited by law. Not valid in California. Your mileage may vary.

  3. #3
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    830
    Rep Power
    8

    what do you mean not working? are you getting an error message?
    Quote of the Month:
    INSIGHT: When the going gets tough, the tough get going. The smart left a long time ago.

    Questions to Ponder:
    Are people more violently opposed to fur rather than leather because it's much easier to harass rich women than motorcycle gangs?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

  4. #4
    Moderator don94403 is a jewel in the rough don94403 is a jewel in the rough don94403 is a jewel in the rough don94403's Avatar
    Join Date
    Mar 2008
    Location
    San Mateo, CA, USA
    Posts
    313
    Blog Entries
    8
    Real Name
    Don Ravey
    Rep Power
    6

    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 to Thread

Similar Threads

  1. Programmatically Add Item to Validation Summary
    By jmurrayhead in forum .NET Code Samples
    Replies: 3
    Last Post: January 18th, 2011, 01:25 PM
  2. display problem checkbox
    By todd2006 in forum JavaScript Programming
    Replies: 4
    Last Post: May 30th, 2008, 04:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO