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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Nisha,

If that variable is mandatory then system should stop the submission. because user is clicking submit before the complete form loads this issue is coming up.

just check why form is taking so long time any onload or ui policy which is impacting the performance

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Hi Ankur,

 

Yes there are 4-5 client scripts which r onLoad. We can't change it.

But can we restrict user to submit the form before it loads properly and mandatory field is filled.

 

Regards,

Nisha

Hi Nisha,

you can use following code; which would do following; you can give a try and check

give the document id of the submit button

1) wait for the complete page to load then show the submit button

function onLoad(){

$(document).ready(function(){
    $("#<buttonId>").show();
});
}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

And what if i want to make the button greyed out for the user until that mandatory field is filled in?