Tiny function to get the form data and validate it. https://codesandbox.io/s/vmv90nno45
npm install getmeformdata --save
const formSpec = { name: { validator: 'required' }, checkbox: { type: 'boolean' } }; function handleOnSubmit(e) { e.preventDefault(); const data = getMeFormData(e.target, formSpec); console.log(data); /*eg. { data:{ name: "", email: "" }, error: { name: "This is required" } }*/ } <form onSubmit={handleOnSubmit}> <input name="name" /> <input name="email"/> <button>Submit</button> </form> }
- npm run build
- npm version patch -m "message"
- npm publish --access public