jQuery Mask Plugin integration with React.js
Simple jsfiddle showing how to integrate jQuery Mask Plugin with React.js
by igorescobar
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
<script src="https://npmcdn.com/react@latest/dist/react-with-addons.js"></script>
<script src="https://npmcdn.com/react-dom@latest/dist/react-dom.js"></script>
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://igorescobar.github.io/jQuery-Mask-Plugin/js/jquery.mask.min.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration-babel.js"></script>
<h1>jQuery Mask Plugin with React</h1>
<h3>Simple example</h3>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
JavaScript 1.7
var Form = React.createClass({
componentDidMount: function() {
$('.date').mask('00/00/0000', {
placeholder: '__/__/____'
});
},
render: function() {
return ( < div >
< form >
< label > Date < /label> <br / >
< input id = "date"
className = "date" / >
< /form> < /div>
);
}
});
ReactDOM.render( < Form / > ,
document.getElementById('container')
);