Removing required Icon based on another field conditions

i want to make Due date field required base on a CF conditions and i do it with below codes in description of related field:

$('#customfield_12813').ready(function(e){
var TypeValue = $("#customfield_12813").val();
if(TypeValue == "11920") {
document.getElementById("duedate").required = false
AJS.$("#duedate").parent().children('label').append('<span class="remove-label" ></span>');
$("#div1").remove();
}
else {
document.getElementById("duedate").required = true

AJS.$("#duedate").parent().children('label').append('<span class="aui-icon icon-required"> required </span>');
}

});
$('#customfield_12813').change(function(e){
var TypeValue = $("#customfield_12813").val();
if(TypeValue == "11920") {
document.getElementById("duedate").required = false
AJS.$("#duedate").parent().children('label').append('<span class="remove-label" ></span>');
}
else {
document.getElementById("duedate").required = true
AJS.$("#duedate").parent().children('label').append('<span class="aui-icon icon-required"> required </span>');

}

});

 but there is two problems

1- when the red star added to lable in required state, it does not change by change of related fields to Value == "11920" and i dont know how to disable the span.

2- i want to add warning text to duedate when click on create issue buttom and it is empty,

thank you so much

1 answer

I Try the below codes and solved my first part of question

 

this part adds the red start:

AJS.$("#duedate").parent().children('label').append('<span class="aui-icon icon-required" > required </span>');

 

and in other conditions below code remive that start:

AJS.$("#duedate").parent().children('label').children('span').remove();

and second part of question is continued.

best regards


Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published yesterday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

72 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you