How to make widget checkbox mandatory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago
i have a checkbox in my widget html:
<label>
<input type="checkbox" ng-model="c.data.accepted" />
correct</label>this is not a mandatory checkbox, how do i make it so?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago
what's the complete business requirement?
share complete widget code
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago
Hi @asd22 ,
Update your widget like below-
HTML code-
<div>
<label class="mandatory">
<span ng-if="c.showError" class="ast">*</span>
<input type="checkbox" ng-model="c.data.accepted"/>
correct
</label>
</div>
<hr>
<button class="btn btn-primary" ng-click="c.submit()">Submit</button>
CSS Code-
.ast {
color: red;
margin-right: 4px;
font-size:20px;
weight: 16px;
}
Client script code-
api.controller=function() {
/* widget controller */
var c = this;
c.submit = function() {
if (!c.data.accepted) {
c.showError = true;
return;
}
c.showError = false;
// continue your submit logic
}
};
Please test and let me know your feedback!!
If you found my response helpful, please mark it as helpful and accept it as the solution.
Thank you
Nawal Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago
we already have a submit button, i cant add a new one. and the widget is huge so its hard for me to show where our submit button is in the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago - last edited 7 hours ago
Hi @asd22
The way above logic is configured in the same way you need to implement your widget.
if you share your code or screenshot then only I can help you otherwise its very hard to understand how you have configured your widget structure!!
take the above logic as example and try to implement.
If you found my response helpful, please mark it as helpful and accept it as the solution.
Thank you
Nawal Singh
