Jump to content

Number of selected Radio Buttons enable Submit Button


Recommended Posts

Hi all,

 

I have a form with 40 radio buttons (single, but grouped) for 20 questions, with 2 radio buttons for each question.

I want to disable submit button on my form UNTIL at least 10 radio buttons are selected (10 questions). I have a div with a messsage "10 Votes Are Required" that shows until 10 radio buttons are selected in the button area, then it turns off and the submit button turns on.. or, at least I want it to after 10 votes are picked.

 

This is what I have so far:

<script language="JavaScript">
	
	document.getElementById("Submit").style.display = 'none';
	
$( "input:radio" ).on( "click", function() {
  if($( "input:radio:checked" ).length >= 2)
  
  {
  	 document.getElementById("Submit").style.display = 'block';
	 document.getElementById("votepromptmsg").style.display = 'none';
	 
  }
  else
  {
  	 document.getElementById("Submit").style.display = 'none';
	  document.getElementById("votepromptmsg").style.display = 'block';
  }  
});
</script>

The code above works on some levels.. but I can't get it to fully do what I want.

Any ideas, or insight, on how to get the code working would be very appreciated.

Thanks, Geoff

Link to comment
Share on other sites

  • 5 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...