A knockout binding to use on labels to indicate whether they are required, and whether the input they are for has been filled out.
All options can optionally be knockout observables
-
isRequired: boolean (optional)- Specifies whether or not to display the required icon. Default state is true. If
isRequiredevaluates to false, then the required label will not show the asterisk, if true, it display.
- Specifies whether or not to display the required icon. Default state is true. If
-
completed: boolean (optional)- The state in which the the required field is in. If
completedevaluates to false, then the default asterisk (*) will be displayed. Ifcompletedevaluates to true, the asterisk will be replaced with the completed icon. - If not provided, then there will be no completed state, and the asterisk will always be visible.
- The state in which the the required field is in. If
-
color: string (optional)- The string value of the color the asterisk.
colorwill take any value that evaluates to a color recognized by CSS. - If not provided, the default color of red will be used.
- The string value of the color the asterisk.
-
completedColor: string (optional)- The string value of the color of the completed state icon.
completedColorwill take any value that evaluates to a color recognized by CSS. - If not provided, the default color of green will be used.
- The string value of the color of the completed state icon.
-
visibilityTransition: function(elem) (optional)- A custom function that will animate the transition between visibility of the
isRequiredproperty. This overwrites the default behavior of just changing the CSSdisplayproperty. Theelemvariable passed in the function is the required label (asterisk) element.
- A custom function that will animate the transition between visibility of the
var options = {
completed: false,
color: 'red',
completedColor: 'green'
}<label data-bind="requiredLabel: options">Required Field</label>