How To add star mark(*) in form that are mandatory for the user to fill it?
If you use the OOTB condition ‘if view/form’ passes validation’ and check the ‘Required’ field, the any controls that are marked as required but not filled out will turn red indicating that it is required.
Otherwise you can add a label, set the text to asterisks, hide it, use a condition like if a control does not contain a value then show the hidden asterisk label. However you will likely also want to consider when to stop the rule executions and when to create/save the data/start the workflow base on these logic.
Hello
<style>
.theme-entry labellname$="_required"]::after {
color: red;
content: "*";
font-size: 1.4rem;
font-weight: 700;
margin-left: 4px;
}
</style>
Then, for all required fields, just add “_requied” to the back of label name for the required control.
Hello
Hi
Hi
I will attempt some screenshots of Deon’s suggestion.
I had to modify the Selector to get Deon’s suggestion to work.
<style>
.theme-entry span.SourceCode-Forms-Controls-Web-Labelename$="_required"]::after {
color: red;
content: "*";
font-size: 1.4rem;
font-weight: 700;
margin-left: 4px;
}
</style>
Notice the part that appears “pname$=_required]”
This will select all labels where the name ends in _required.
Also note the “::after”, this will add a decoration defined in the class {}
In this case the content is our “*” content with formatting.
3 controls,
1 with the _required name
1 without the _required name
1 for injecting the CSS.
Notice that Literal is Checked and Prevent XSS is Unchecked.
I use Expression whenever I do these types of injections.
So any label with a name property ending in _required will get a red star after it.
Yeah, sorry forgot to mention that if you change the style of the label from “Normal” to “Input Label”, K2 actually changes the tag being rendered from <span> to <label>
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.