Skip to content

Instantly share code, notes, and snippets.

@haldarmahesh
Last active October 9, 2020 16:35
Show Gist options
  • Select an option

  • Save haldarmahesh/05144ff2acaa8add019dff0baec36550 to your computer and use it in GitHub Desktop.

Select an option

Save haldarmahesh/05144ff2acaa8add019dff0baec36550 to your computer and use it in GitHub Desktop.
class MyFrom extends Component {
constructor(props) {
super(props);
this.state = {phoneNumber: ''};
this.handleChangePhoneNumber = this.handleChangePhoneNumber.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChangePhoneNumber(event) {
this.setState({value: event.target.value});
}
handleSubmit(event) {
alert('Hi your phone Number is: ' + this.state.value);
event.preventDefault();
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<label>
Phone Number:
<input type="text" value={this.state.value} onChange={this.handleChangePhoneNumber} />
</label>
<input type="submit" value="Submit" />
</form>
);
}
}
@oskarleonard
Copy link
Copy Markdown

this.setState({phoneNumber: event.target.value});
value={this.state.phoneNumber}

@fgarend
Copy link
Copy Markdown

fgarend commented Oct 9, 2020

Hi, there is a typo in the class name MyFrom > MyForm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment