I want to perform two events inside an input, how can I call them both continuously or how should I declare the method? I tried the following way but it throws me an error, could you give me some suggestion?
my entry
<input style={styles.input} placeholder='Introduce tu nombre' type='text'
name={this.state.nombre} onChange={this.bChange, this.hChange}>
and the events
hChange(e) {const name = e.target.value;
this.setState({input:name});
this.props.cambioNombre(name); }
bChange(e) {const letras= e.target.value;
if(letras >= 4) {
this.setState({habilitado:false});
} else if (!this.state.habilitado) {
this.setState({habilitado:true});
} }
In case of using React.js you can do it like this:
In case of vanilla JavaScript you can do it like this:
separates the functions in the
onChange
with;
so that they are executed at the time of fulfilling the event.