Skip to content

Instantly share code, notes, and snippets.

@sophiebits
Forked from samspot/gist:8837797
Last active August 29, 2015 13:56
Show Gist options
  • Save sophiebits/8838019 to your computer and use it in GitHub Desktop.
Save sophiebits/8838019 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-shim.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-sham.js"></script>
<script src="http://fb.me/react-0.8.0.min.js"></script>
<script src="http://fb.me/JSXTransformer-0.8.0.js"></script>
<script type="text/jsx">
/** @jsx React.DOM */
var InputBox = React.createClass({
onKeyUp: function(e){
var value = this.refs.mask.getDOMNode().value.trim();
this.refs.mask.getDOMNode().value = "-" + value;
},
render: function(){
return (
<form>
<input type="text" placeholder="Something to mask"
ref="mask" onKeyUp={this.onKeyUp} />
</form>
);
}
});
React.renderComponent(
<InputBox />,
document.getElementById('content')
);
</script>
</head>
<body style="font-size: 1.5em">
<h1>Let's React</h1>
<div id="content"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment