HTML-First API
Use `data-ctrovalidate-rules` to define validation directly on your inputs. Keep logic clean and readable.
Lightweight, accessible, and zero-dependency. TypeScript-native with 98% test coverage. Define rules in HTML, handle the rest in JS.
Define validation rules in HTML attributes. Ctrovalidate handles the validation logic, error display, and accessibility.
<!-- Define rules directly in HTML -->
<div class="form-group">
<input
type="email"
name="user_email"
data-ctrovalidate-rules="required|email"
/>
<div class="error-message"></div>
</div>import { Ctrovalidate } from 'ctrovalidate';
// Initialize with configuration options
const validator = new Ctrovalidate(
document.querySelector('form'),
{ realTime: true }
);
// Validate programmatically
const isValid = await validator.validate();Ctrovalidate works with any JavaScript framework or vanilla JS.
| Framework | Status | Demo | Documentation |
|---|---|---|---|
| Vanilla JS | โ | View Demo | Guide |
| React 18+ | โ | View Demo | Integration |
| Next.js 15+ | โ | View Demo | Integration |
| Vue 3 | โ | View Demo | Integration |
| Alpine.js | โ | View Demo | Integration |
| Svelte | โ | - | Integration |
| HTMX | โ | - | Best Practices |
Styling: Works with Tailwind CSS, CSS Modules, Vanilla CSS, Bootstrap, or any CSS framework.
Install via npm and start validating forms in minutes.
npm install ctrovalidateRead the Documentation ยท View API Reference ยท See Examples