heilhead / react-bootstrap-validation

Form validation for react-bootstrap
MIT License
136 stars 50 forks source link

How to trigger validation out of the form tag #18

Closed mark-wang-sh closed 8 years ago

mark-wang-sh commented 8 years ago
<Form ref="myForm" onValidSubmit={this._handleValidSubmit} onInvalidSubmit={this._handleInvalidSubmit}>
    <ValidatedInput name='Name' type="text" bsSize="medium" label="Name" validate='required' />
    <ButtonInput type='submit' bsStyle="success" value='Save'/>
</Form>
<Button onClick={this.validationMyForm}>Close</Button>

how to trigger validation in funcion validationMyForm

heilhead commented 8 years ago

Hang tight, I'm adding submit method to form in the next release that you'll be able to call like this:

this.refs.myForm.submit();

This will trigger both validation and valid/invalid callbacks.

The release should be ready later today.