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

This widget could not be displayed.

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 Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published 8 hours ago in Marketplace Apps

The 7 hacks of highly successful automation

...there's anything I've learnt from working, it's that people are lazy! No offense to anyone reading this, but it's true and we can all admit it. The easier you make something for someone, the more...

42 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