JavaScript/jQuery Form - Additional Marks

Simple items may require a value or may allow a user to skip it. Both types of items can be marked with a symbol or text. Required items are those whose isRequired property is true, others are considered optional.

To specify the mark or text for required and optional items, use the requiredMark and optionalMark properties. Note that the "optional" mark will not be displayed until you set the showOptionalMark property to true. You can also hide the "required" mark using the showRequiredMark property.

App.js
  • import React from 'react';
  •  
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { Form, SimpleItem } from 'devextreme-react/form';
  •  
  • const employee = {
  • firstName: 'John',
  • lastName: 'Heart',
  • position: 'CEO'
  • };
  •  
  • class App extends React.Component {
  • render() {
  • return (
  • <Form
  • formData={employee}
  • requiredMark="!"
  • optionalMark="opt"
  • showOptionalMark={true}>
  • <SimpleItem dataField="firstName" isRequired={true} />
  • <SimpleItem dataField="lastName" isRequired={true} />
  • <SimpleItem dataField="position" />
  • </Form>
  • );
  • }
  • }
  •  
  • export default App;

Each label ends with a colon. To hide it, assign false to the showColonAfterLabel property. Note that you can show/hide a colon for an individual item using the label.showColon property.

App.js
  • import React from 'react';
  •  
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { Form, SimpleItem, Label } from 'devextreme-react/form';
  •  
  • const employee = {
  • firstName: 'John',
  • lastName: 'Heart',
  • position: 'CEO'
  • };
  •  
  • class App extends React.Component {
  • render() {
  • return (
  • <Form
  • formData={employee}
  • showColonAfterLabel={false}>
  • <SimpleItem dataField="firstName" />
  • <SimpleItem dataField="lastName" />
  • <SimpleItem dataField="position">
  • <Label showColon={true} />
  • </SimpleItem>
  • </Form>
  • );
  • }
  • }
  •  
  • export default App;
See Also