Skip to content

Instantly share code, notes, and snippets.

@tilsammans
Last active December 20, 2015 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tilsammans/de3a3881883d6c8e4b2e to your computer and use it in GitHub Desktop.
Save tilsammans/de3a3881883d6c8e4b2e to your computer and use it in GitHub Desktop.
var PostcodeCheck = React.createClass({
// omitting existing code for brevity
getInitialState: function() {
return {
postcode: '',
housenumber: '',
housenumberAddition: '',
result: ''
};
},
validatePostcode: function(e) {
this.setState({result: '', postcode: e.target.value.
substr(0, 7).
toUpperCase()});
},
validateHousenumber: function(e) {
this.setState({result: '', housenumber: e.target.value.
replace(/\D/g,'')});
},
validateHousenumberAddition: function(e) {
this.setState({result: '', housenumberAddition: e.target.value.
toUpperCase()});
},
render: function() {
return (
<section>
<h2>Postcodecheck</h2>
<p>Check hier of u al een vergunning kunt aanvragen met BLITTS.</p>
<form id="postcodecheck" onSubmit={this.handleSubmit}>
<p>Uw postcode/huisnummer/toevoeging:</p>
<input id="postcode" placeholder="1234AA" value={this.state.postcode} onChange={this.validatePostcode}/>
<input id="housenumber" placeholder="1" value={this.state.housenumber} onChange={this.validateHousenumber}/>
<input id="housenumber_addition" value={this.state.housenumberAddition} onChange={this.validateHousenumberAddition}/>
<input type="submit" value="Check!" className="next-button"/>
<p className="postcodecheck-result">{this.state.result}</p>
</form>
</section>
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment