reactjs - disable on enter click submit form event -
i have form having single input type ....when click enter form submited how disable on enter submit form event ???
import react, {component, proptypes} 'react' import formsy 'formsy-react' export class businessdetailsform extends component { constructor(props) { super(props) this.state = { state: '', city: '' } this.submitform = this.submitform.bind(this) } submitform(data) { if (this.state.googleinputvalue !== '') { this.props.dispatch(setsubmitting(true)) dispatch(signupstep2(data)) } else { this.setstate({ locationerrmsg: 'please select location'}) } } render() { return ( <div> <formsy.form onsubmit={this.submitform} id="form_validation"> <element name="location"> <field type="text" name="location" component={googleautocomplete} floatinglabeltext="location" hinttext="location" id="addresssearchboxfield" defaultvalue={this.state.location} onselectplace={this.handleplacechanged} onchangeinput={this.handleinputchange.bind(this)} /> </element> <span style={{color: 'red'}}>{this.state.locationerrmsg}</span> <span> <raisedbutton type="submit" label="next" disabletouchripple disablefocusripple //ontouchtap={this.handlenext} style={{marginright: '12px', color:"#c5c5c5"}} /> </span> </formsy.form> </div> )}}
as in jquery
can listen keydown
event , prevent default action like
_handleenterkey(event) { if(event.keycode == 13){ e.preventdefault(); return false; } } componentdidmount() { document.addeventlistener("keydown", this._handleenterkey, false); } componentwillunmount() { document.removeeventlistener("keydown", this._handleenterkey, false); }
Comments
Post a Comment