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

Hi,

if the above code works fine then it won't show the submit button unless complete form/page loads

not sure on the greyed out option.

Regards

Ankur

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

where we will use this code. do i need to create a new client script(onLoad)

Yes create an onLoad client script.

Regards

Ankur

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

I am using this code in the onLoad client script on order guide form(sc_cat_item_guide) to make the Submit button invisible on form load but its not working can you pls help me here...

 

function onLoad() {

     document.getElementById('submit').style.display='none';
}

Hi Nisha,

Can you check it with this?

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

$("#submit").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