Restrict request submission if mandatory field is not filled in.

nisha2606
Kilo Expert

Hello Everyone,

 

I have a scenario in my order guide that when form is not loaded completely user directly clicks on submit button without filling the mandatory field and REQ is created but with no details.

 

So, can anyone suggest me how can I give an alert to the user that if he clicks on submit button without filling the mandatory field the REQ shouldn't be submitted.

 

Regards,

Nisha

1 ACCEPTED SOLUTION

nisha2606
Kilo Expert

For this i used ng-if directive with submit button, which made submit button to become visible after the user selected option in mandatory field.

<button ng-if="!hasMandatory()" ng-disabled="submitted" name="submit" ng-click="triggerOnSubmit()" class="btn btn-primary">{{submitButtonMsg}}</button>
<span ng-if="submitting" style="padding-left:4px">${Submitting...}</span>

This solved my issue. 🙂

 

Thanks everyone for all your inputs.

 

Regards,

Nisha

View solution in original post

16 REPLIES 16

Not working.

I am not sure if I am using the code correctly.

 

Regards,

Nisha

Hi Nisha,

Can you check by adding an alert inside that also check document id of submit button is proper

function onLoad(){
$j
(document).ready(function()
{

alert('inside form load complete and before showing');

$j("#submit").show();

});
}

}

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

This code will work for ITIL view. But the button which I want to hide on Load is on service portal view. So, can we use any angular directive or something to hide this submit button until the mandatory field is filled in.

 

Attached below is screenshot of the view which I am referring to here...

 

Regards,

Nisha

Hi Nisha,

So is that code working fine in native. For Service portal you can use angular directive but not sure on that since not worked on that.

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

manish64
Giga Guru

just check whether you have checked ignore mandatory validation it should be unchecked

Please, remember to mark Correct or Helpful if you find my response useful.