Removing required Icon based on another field conditions

Crs co June 7, 2016

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

0 votes
Crs co June 7, 2016

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