Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3947
  • Last Modified:

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

0
christamcc
Asked:
christamcc
1 Solution
 
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

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now