-
Notifications
You must be signed in to change notification settings - Fork 70
Unable to add asterisk or star for the required fields labels #198
Comments
There are many ways to go about this. The easiest is to just add https://stackblitz.com/edit/reactstrap-validation-v2-mbkhus?file=Example.js |
@TheSharpieOne adding * to lable it not the best way, as if we keep adding start with each label how we will colour it to red and label remains black, |
That is where the utility/helper function I mentioned comes in very handy. Then you don't need to add import React from 'react';
import { AvField } from 'availity-reactstrap-validation';
const MyField = ({label, ...rest}) => {
if (rest.required) {
label = <>{label}<sup>*</sup></>;
}
return <AvField label={label} {...rest} />;
}
export default MyField; https://stackblitz.com/edit/reactstrap-validation-v2-6tmcc4?file=MyField.js |
Following is my code and want to add star to the required fields,
<AvField type='text' id='ClusterName' name='ClusterName' label={'ClusterName'} placeholder={'Cluster_Name'} value={""} validate={{ required: {value: true, errorMessage: 'Cluster_Name'}, pattern: {value: '^[A-Za-z0-9._-]+(?: +[A-Za-z0-9._-]+)*$', errorMessage: 'MSG_Validation_Cluster'}, }} />
Cant find any options to apply star to required fields.
The text was updated successfully, but these errors were encountered: