Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ A [live playground](https://mozilla-services.github.io/react-jsonschema-form/) i
- [Custom descriptions](#custom-descriptions)
- [Form data validation](#form-data-validation)
- [Live validation](#live-validation)
- [HTML5 validation](#html5-validation)
- [Custom validation](#custom-validation)
- [Error List Display](#error-list-display)
- [Styling your forms](#styling-your-forms)
Expand Down Expand Up @@ -1137,6 +1138,10 @@ Be warned that this is an expensive strategy, with possibly strong impact on per

To disable validation entirely, you can set Form's `noValidate` prop to `true`.

### HTML5 Validation

By default, required field errors will cause the browser to display its standard HTML5 `required` attribute error messages and prevent form submission. If you would like to turn this off, you can set Form's `noHtml5Validate` prop to `true`, which will set `noValidate` on the `form` element.

### Custom validation

Form data is always validated against the JSON schema.
Expand Down
6 changes: 5 additions & 1 deletion src/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default class Form extends Component {
noValidate: false,
liveValidate: false,
safeRenderCompletion: false,
noHtml5Validate: false
}

constructor(props) {
Expand Down Expand Up @@ -138,7 +139,8 @@ export default class Form extends Component {
action,
autocomplete,
enctype,
acceptcharset
acceptcharset,
noHtml5Validate
} = this.props;

const {schema, uiSchema, formData, errorSchema, idSchema} = this.state;
Expand All @@ -155,6 +157,7 @@ export default class Form extends Component {
autoComplete={autocomplete}
encType={enctype}
acceptCharset={acceptcharset}
noValidate={noHtml5Validate}
onSubmit={this.onSubmit}>
{this.renderErrors()}
<_SchemaField
Expand Down Expand Up @@ -201,6 +204,7 @@ if (process.env.NODE_ENV !== "production") {
enctype: PropTypes.string,
acceptcharset: PropTypes.string,
noValidate: PropTypes.bool,
noHtml5Validate: PropTypes.bool,
liveValidate: PropTypes.bool,
safeRenderCompletion: PropTypes.bool,
formContext: PropTypes.object,
Expand Down
7 changes: 6 additions & 1 deletion test/Form_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,8 @@ describe("Form", () => {
action: "/users/list",
autocomplete: "off",
enctype: "multipart/form-data",
acceptcharset: "ISO-8859-1"
acceptcharset: "ISO-8859-1",
noHtml5Validate: true
};

let node;
Expand Down Expand Up @@ -1175,5 +1176,9 @@ describe("Form", () => {
it("should set attr acceptcharset of form", () => {
expect(node.getAttribute("accept-charset")).eql(formProps.acceptcharset);
});

it("should set attr novalidate of form", () => {
expect(node.getAttribute("novalidate")).not.to.be.null;
});
});
});