Install @andresclua/validate from npm and get started with form validation in seconds.
Install the package using npm:
npm install @andresclua/validate
Import a validator and use it on your form inputs:
import { isEmail } from '@andresclua/validate'
const emailInput = document.getElementById('email')
const validation = isEmail(emailInput.value)
if (validation.valid) {
console.log('Email is valid!')
} else {
console.log('Error:', validation.message)
}
If you prefer not to use npm, you can use the UMD build directly in the browser:
<script src="https://unpkg.com/@andresclua/validate/dist/validate.umd.js"></script>
<script>
const { isEmail } = window.validate
// Use isEmail...
</script>
Now that you have validate installed, explore the different validators. Start with email validation or browse all available validators in the sidebar.