Way to use validator.js with ReactJS?

时间:2019-04-08 12:48:39

标签: reactjs validation

I want to use validator.js to do some validation on my form input. I just want to know what is the best way to use it, or if it exist an other lib to do validation whitout changing my html.

1 个答案:

答案 0 :(得分:0)

最好的方法是install validator.js from npm

npm install validator

用法:

import validator from 'validator';

// example
validator.isEmail('foo@bar.com'); // use it in handleChange or functions being called

我希望这会有所帮助。这是 npm

的链接