UI Page, Reference field mandatory not working

SNOW44
Mega Guru

Hello All,

In UI Page i'm using the reference field and want to make mandatory. As it is used pop-up in incident form.

I have used  required="required" mandatory="mandatory" required="true" required="required".

Even it is not working and lastly I used 

HTML

<script>
document.getElementById('inputLabel').setAttribute("class", "required");
</script>
<style>
label.required::before {
content: '*';
margin-right: 4px;
color: red;
}
label.notrequired::before {
content: '*';
margin-right: 4px;
color: grey;
}
</style>

 

In Client script :

calling this function from reference field in HTML
function updateCost(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
gel('targetServiceCost').value = answer;
}

working but UI page is submitted with filling the reference field.

can anyone advice me

1 ACCEPTED SOLUTION

Ashley Snyder1
Giga Guru

 

 

Your client script looks like it's attempting to fill in the field value but not checking to see if it's empty before submitting, is your button calling updateCost or another function? 

You need some sort of validation checking such as:

var costField = gel('targetServiceCost').value;

if (costField == ' ') {

gel('targetServiceCost').required = true;

}

View solution in original post

3 REPLIES 3

Ashley Snyder1
Giga Guru

 

 

Your client script looks like it's attempting to fill in the field value but not checking to see if it's empty before submitting, is your button calling updateCost or another function? 

You need some sort of validation checking such as:

var costField = gel('targetServiceCost').value;

if (costField == ' ') {

gel('targetServiceCost').required = true;

}

Hello Ashley,

Thanks for response

asifnoor
Kilo Patron

Hi,

Refer to this link. This might help you.

https://community.servicenow.com/community?id=community_question&sys_id=ac08c0f1db999c105129a851ca96...

Mark the comment as a correct answer and helpful if this helps to solve the problem.