rozszczepienie JS
npm install --save cleave.js
Light Leopard
npm install --save cleave.js
import React from 'react';
import ReactDOM from 'react-dom';
import Cleave from 'cleave.js/react';
class MyComponent extends React.Component {
onChange(event) {
// formatted pretty value
console.log(event.target.value);
// raw value
console.log(event.target.rawValue);
}
render() {
return (
<Cleave placeholder="Enter your credit card number"
options={{creditCard: true}}
onChange={this.onChange.bind(this)} />
);
}
}
<script src="cleave.min.js"></script>
<script src="cleave-phone.{country}.js"></script>
var cleave = new Cleave('.input-element', {
creditCard: true,
onCreditCardTypeChanged: function (type) {
// update UI ...
}
});