
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
just-validate
Advanced tools
Modern, simple, lightweight (~5kb gzip) form validation library written in Typescript, with no dependencies (no JQuery!). Support a wide range of predefined rules, async, files, dates validation, custom error messages and styles, localization. Support wri
Modern, simple, lightweight (~5kb gzip) form validation library written in Typescript, with no dependencies (no JQuery!). Support a wide range of predefined rules, async, files, dates validation, custom error messages and styles, localization. Supporting writing custom rules and plugins.
It's a right choice for you, if you have a site, a landing page without React, JQuery etc. and you want to quick, simple and powerful solution for validating your form.
npm install just-validate --save
yarn add just-validate
And then use it as an imported module:
import JustValidate from 'just-validate';
const validate = new JustValidate('#form');
Or if you don't use module bundlers, just include JustValidate script on your page from CDN and call it as window.JustValidate:
<script src="https://unpkg.com/just-validate@latest/dist/just-validate.production.min.js"></script>
<body>
<script>
const validate = new window.JustValidate('#form');
</script>
</body>
There are plenty of rules which you could use out of the box:
Let's say we have a basic HTML layout:
<form action="#" id="form" autocomplete="off">
<label for="name">Enter your name</label>
<input
type="text"
class="form__input form-control"
placeholder="Enter your name"
autocomplete="off"
name="name"
id="name"
/>
<label for="email">Enter your email</label>
<input
type="email"
class="form__input form-control"
placeholder="Enter your email"
autocomplete="off"
name="email"
id="email"
/>
<button class="btn btn-primary" id="submit-btn">Submit</button>
</form>
Next, let's add JustValidate to our layout and define some simple rules.
First, we should create the instance new JustValidate('#form') by passing a form selector, or the element as an argument.
Second, we call .addField() with a field selector as the first argument and an array of rules as the second argument.
const validation = new JustValidate('#form');
validation
.addField('#name', [
{
rule: 'minLength',
value: 3,
},
{
rule: 'maxLength',
value: 30,
},
])
.addField('#email', [
{
rule: 'required',
errorMessage: 'Email is required',
},
{
rule: 'email',
errorMessage: 'Email is invalid!',
},
]);
And that's it! Now our form is validated!
Please, check out the examples and documentation. Or try the playground.
FAQs
Modern, simple, lightweight (~5kb gzip) form validation library written in Typescript, with no dependencies (no JQuery!). Support a wide range of predefined rules, async, files, dates validation, custom error messages and styles, localization. Support wri
We found that just-validate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.