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
Community showcase
Published Monday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

368 views 0 8
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