form-validator-lite
v1.0.6
Published
A lightweight form validation library for HTML forms.
Downloads
415
Readme
Form Validator Lite
A lightweight form validation library for HTML forms.
Installation
Via npm
npm i form-validator-lite
Via CDN
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/form-validator-lite.min.js"></script>
Features
- Component-based architecture
- Simple router
- State management
Usage
Using NPM
import FormValidator from "form-validator";
const validator = new FormValidator("#myForm");
Using CDN
<form id="myForm">
<label>
Name:
<input type="text" name="name" data-validate="required|text" />
</label>
<label>
Age:
<input type="text" name="age" data-validate="required|number" />
</label>
<label>
Username:
<input type="text" name="username" data-validate="alphanumeric|min:5|max:15" />
</label>
<label>
Mobile Number:
<input type="text" name="mobile" data-validate="mobile" />
</label>
<label>
PAN Number:
<input type="text" name="pan" data-validate="pan" />
</label>
<label>
Aadhaar Number:
<input type="text" name="aadhaar" data-validate="aadhaar" />
</label>
<button type="submit">Submit</button>
</form>
<!-- Include the validator -->
<script src="https://cdn.jsdelivr.net/npm/form-validator-lite@latest/dist/form-validator-lite.min.js"></script>
<script>
const validator = new FormValidator("#myForm");
</script>