Jquery Removing Required Attribute on Input

I would like to do one other thing in these conditionals.  I would like to change the "required" attribute for the field with id='band'.  See the //****** in the following code that needs to be replace with those commands.

Thanks!

<script type="text/javascript">
	 	//Show or don't show the artist information fields
	 		$(document).ready(function() {
				if( $('#upgradeaccount').length == 0 ){
					$('#artist_fields').hide();
					$("#general, #artist").change(function () {
                        
						if ($("#general").attr("checked")) {
							
							//HIDE artist form
							$('#artist_fields').hide();
							//**** remove 'required' property from #band 
                        }
						
                        if ($("#artist").attr("checked")) {
							
							//SHOW artist form
							$('#artist_fields').show('fast');
                                                    / /**** add 'required' property to  #band 
                        }
                    }); 
				}
				});	
      </script>

Open in new window

christamccAsked:
Who is Participating?
 
Julian HansenCommented:
if ($("#general").attr("checked")) {
  //HIDE artist form
  $('#artist_fields').hide();
  //**** remove 'required' property from #band 
  $('#band').removeAttr('required');
}

...

if ($("#artist").attr("checked")) {
  //SHOW artist form
  $('#artist_fields').show('fast');
  $('#band').attr('required','required');
}

Open in new window

1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.