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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted 4 hours ago in Confluence

Calling all marketing teams who use Confluence - we want to hear from you!

Hi Community! me again 🙂 If you’re a marketing team using Confluence, we want to hear your story! How did you start using Confluence? What are your use cases? What have been some of the benefits?...

29 views 1 2
Join discussion

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