- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2018 02:24 AM
Morning all, hopefully just a nice simple one for all those experts out there. Being new to scripting I have no idea how to complete this. I have created a custom widget that shows a number of fields which logs a request on your service desk. However there are two fields that i simply want to make mandatory and show in red if they are not filled in when the submit button is pressed or something similar, whatever is easiest. The existing code is as below, the fields to be mandatory are the Reason for nomination and value examples controls towards the bottom of the HTML template
HTML:
CS:
Server:
Any advice on the quickest simplest way to do this would be greatly appreciated
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2018 03:23 AM
Hi,
Here, I just give you one example. I hope this may help.
In HTML:-
<label style="color:red">{{m1}}</label><label>You text1</label>
<label style="color:red">{{m2}}</label><label>You text2</label>
<button ng-click="c.addItem()">Save</button>
In Client script:
c.addItem = function()
{
if(!model1 && !model2)
{
$scope.m1 = "*";
$scope.m2 = "*";
}
else if(!model1)
{
$scope.m1 = "*";
}
else if(!model2)
{
$scope.m2 = "*";
}
else
{
/*your code*/
}
}
Note: You will use your ng-model variable names in place of model1 and model2.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2018 03:23 AM
Hi,
Here, I just give you one example. I hope this may help.
In HTML:-
<label style="color:red">{{m1}}</label><label>You text1</label>
<label style="color:red">{{m2}}</label><label>You text2</label>
<button ng-click="c.addItem()">Save</button>
In Client script:
c.addItem = function()
{
if(!model1 && !model2)
{
$scope.m1 = "*";
$scope.m2 = "*";
}
else if(!model1)
{
$scope.m1 = "*";
}
else if(!model2)
{
$scope.m2 = "*";
}
else
{
/*your code*/
}
}
Note: You will use your ng-model variable names in place of model1 and model2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2018 03:23 AM
Hi there, many thanks for the reply but I seem to be missing something. I'm newbie to this so have now idea where to look.
I have the below in HTML
<div class="form-group">
<label style="color:red">{{m1}}</label><label>Reason for nomination (Please be as detailed as possible to help us in the selection process)</label>
<input class="form-control" name="value" ng-model="c.data.u_nomination_reason" required>
</div>
<div class="form-group">
<label style="color:red">{{m2}}</label><label>Give some examples where you think the nominee has 'lived' the values.</label>
<input id="value" name="value2" class="form-control"required minlength="10" ng-model="c.data.u_value_examples" >
</div>
and the below in my client script:
For some reason now the two boxes referenced to do display red and my submit button does nothing am I using the wrong name or is the code incorrect in some way?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2021 04:15 AM
Thanks Bhagya Lakshmi,
The code snippet was quite helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2018 03:59 AM
Ignore the last post I now have it working through a bit of trial and error, many thanks for your help