CDN Name : KilValidate  ( Kil Validation)

This JavaScript package provides input field validation for web forms. It includes methods for validating various types of form fields, such as text fields, email, phone numbers, and custom patterns.

Installation
Kilvish Validation Attributes

This README describes the custom validation attributes (data-kilvish-*) used in your project for various input field types. These attributes are used to enforce constraints on the data entered into form fields.

Overview: These data-kilvish-* attributes are designed to ensure that the input provided in form fields adheres to specific validation rules, such as numbers only, alphanumeric characters, or specific special characters. Below is a breakdown of the available attributes.

Validation Attributes:

For Numbers Only
Attribute: data-kilvish-num='yes'

This attribute ensures that the input is a numeric value only.

Example:

For Numbers Only with Limits (Character Length)
Attribute: data-kilvish-num='_7_20'

This attribute restricts the input to numeric values only, and the length of the number must be between 7 and 20 characters.

Example:

For Alphanumeric Characters Only
Attribute: data-kilvish-char='mix'

This attribute allows only alphanumeric characters (letters and numbers).

Example:

For Alphanumeric Characters with Special Characters
Attribute: data-kilvish-char='mix_%_$'

This attribute allows alphanumeric characters along with specific special characters (%, _, and $).

Example:

or data-kilvish-char='mix_ ,-_' // ideal for address contain space , dash, comma

For Alphabets Only (Letters Only)
Attribute: data-kilvish-char='Yes'

This attribute restricts the input to alphabets (letters only, no numbers or special characters).

Example:

For Alphabets Only with Special Characters Allowed
Attribute: data-kilvish-char='Yes_%_$'

This attribute allows alphabets and special characters (%, _, and $).

Example:

File Input Validation with data-kilvish-file
7.1 -> use data-kilvish-file="image" or no use for simple Image

7.2 data-kilvish-file="image_min_max"

Example: data-kilvish-file="image_1_3" restricts the selection to between 1 and 3 image files.
7.3 data-kilvish-file="doc" for pdf , word , excel

7.4 data-kilvish-file="doc_min_max" Example: data-kilvish-file="doc_1_4" restricts the selection to between 1 and 4 document files.

7.5 data-kilvish-file="pdf" only allow pdf

7.6 data-kilvish-file="pdf_min_max"

Example: data-kilvish-file="pdf_1_4" restricts the selection to between 1 and 4 PDF files.
7.7 data-kilvish-file="mix" // for allow both image or doc

7.8 data-kilvish-file="only_pdf_image" → Only PDF and image files will be accepted.

7.9 data-kilvish-file="only_doc_image" → Only DOC-related and image files will be accepted.

Example: // limits to 1–4 files




## Password

### Length & composition
- `data-kilvish-password="MIN_MAX"` – requires:
  - at least one lowercase, one uppercase, one digit, one special character
  - **no sequential runs** like `1234` or `abcd`
- Example: `data-kilvish-password="8_20"` ⇒ min 8, max 20.

### Eye icon (show/hide)
An eye icon is auto-injected at the end of every password field and stays inside the input (works with/without `.input-group`).

**Attributes**
- `data-kileye-show` — behavior mode:
  - `hold` *(default if omitted)*: press & hold to show; release/blur to hide
  - `toggle`: click to show/hide
  - `fix`: start visible; click to hide/show (no holding needed)
- `data-kileye-initial` — initial visibility: `on` | `off` *(default `off`; `fix` forces visible)*
- `data-kileye-color` — icon color (e.g., `#005555`)
- `data-kileye-false` — disable auto eye for this field

> The validator reserves right padding so text never sits under the icon. The eye stays fixed inside the field, the strength bar stays visible below it, and the detailed rule list only shows while the password field is focused and has input.








data-kilvish-amount // for setting amount or Price related validation
Case 1: data-kilvish-amount="USD" Input: 2 → Auto-formats to 2.00 with cursor at 2|.00. Input: 25. → Allows further typing for decimal values, e.g., 25.5 or 25.55. Input: 25.555 → Automatically truncates to 25.55.

Case 2: data-kilvish-amount="USD_200_1000" Input: 150 → Shows error: Amount must be at least 200.00 USD. Input: 250.333 → Automatically truncates to 250.33. Input: 1100 → Shows error: Amount must not exceed 1000.00 USD.

data-kilvish-date // Date Validations with # Date Validations with data-kilvish-date
Example: <input type="date" data-kilvish-date="_18_60">
Ensures the user is between 18 and 60 years old.

10.1 Future Date Restrictions data-kilvish-date="future"
Ensures the date must be in the future.

Example: <input type="date" data-kilvish-date="future">

The selected date must be after today.
Example: <input type="date" data-kilvish-date="today_future">

The selected date can be today or in the future.
Example: <input type="date" data-kilvish-date="30_days_future">

The selected date must be within the next 30 days.

Example: <input type="date" data-kilvish-date="2_years_future">

The date must be within the next 2 years.

Example: <input type="date" data-kilvish-date="2_years_after">

The date must be after 2 years from today

10.2 Past Date Restrictions data-kilvish-date="2_years_past"
Ensures the date must be in the past.

Usage: data-kilvish-date="past"

Example: <input type="date" data-kilvish-date="past">

The date must be within the past 2 years.
Example: <input type="date" data-kilvish-date="10_years_past">

The date must be within the past 10 years.

Example: <input type="date" data-kilvish-date="2_years_before">

The date must be before 2 years ago.
10.3 Date Range (Custom) data-kilvish-date="Between_2024_2025"
Ensures the date falls within a specific range of years.

Usage: data-kilvish-date="Between_startYear_endYear"
Example: <input type="date" data-kilvish-date="Between_2000_2010">
Ensures the date is between 2000 and 2010.
Example: <input type="date" data-kilvish-date="Between_1920_1985">
Ensures the date is between 1920 and 1985.
10.4 Relative Date Validation data-kilvish-date="from_2023" OR "till_2025"
Allows validation based on specific starting or ending years.

Usage: data-kilvish-date="from_year" or data-kilvish-date="till_year"
Example: <input type="date" data-kilvish-date="from_2023">
The date must be from 2023 onwards.
Example: <input type="date" data-kilvish-date="till_2025">
The date must be till 2025 (including 2025 but not beyond).
10.5 Date Should Not Be Today - data-kilvish-date="not_today"
Prevents users from selecting today's date.

Usage: data-kilvish-date="not_today"
Example: <input type="date" data-kilvish-date="not_today">
Today's date is not allowed.
10.6 Weekday or Weekend Restrictions data-kilvish-date="weekend"  OR "weekday"
Restricts the date to either a weekday or a weekend.

Usage: data-kilvish-date="weekday" or data-kilvish-date="weekend"
Example: <input type="date" data-kilvish-date="weekday">
The selected date must be a Monday to Friday.
Example: <input type="date" data-kilvish-date="weekend">
The selected date must be a Saturday or Sunday.
10.7 Exact Age Validation data-kilvish-date="exact_18"
Ensures the user is a specific age.

Usage: data-kilvish-date="exact_age"
Example: <input type="date" data-kilvish-date="exact_18">
The user must be exactly 21 years old.
10.8 Specific Days Validation data-kilvish-date="first_of_month" OR "last_of_month"
Restricts the date to the first or last day of the month.

Usage: data-kilvish-date="first_of_month" or data-kilvish-date="last_of_month"
Example: <input type="date" data-kilvish-date="first_of_month">
The selected date must be the first day of any month.
Example: <input type="date" data-kilvish-date="last_of_month">
The selected date must be the last day of any month.
10.9 Leap Year Validation ( NOt Developed Yet - Do NOt Use )
Ensures the date falls in a leap year.

Usage: data-kilvish-date="leap_year"
Example: <input type="date" data-kilvish-date="leap_year">
The selected date must be in a leap year.
10.10 Combining Multiple Conditions ( NOt Developed Yet - Do NOt Use )
You can combine multiple conditions using _.

Example: <input type="date" data-kilvish-date="future_weekday">
The selected date must be a future date and a weekday.
Example: <input type="date" data-kilvish-date="past_30_days">
The selected date must be in the past, but within the last 30 days.
10.10 IF Age should be not pass perticular years in the Past or Future ( Old technique)
user in input name='kildate' and put data-kilvish-date='_18_100' and type='date' You can combine multiple conditions using _.

Example: <input type="date" data-kilvish-date="_18_100">
Birthday cannot be less than 18 years ago or more than 100 years in the future.**.
10.11 Date Group Validation — Start and End Dates (data-kilvish-dategroup)
This attribute links two related date or month inputs (such as employment start and end dates) to enforce a logical sequence — for example, the "From" date should not be after the "To" date.

Format: data-kilvish-dategroup="X_Y" Y will be 1 or 2 ...so on

data-kilvish-date_name is optional if you want validaion of (fromDate to Todate )

data-kilvish-dategroup="GROUP_1" & data-kilvish-date_name
data-kilvish-dategroup="GROUP_2" & data-kilvish-date_name

X is any unique group identifier (e.g., A, EMP, SCHOOL)

Y is 1 or 2

1 should be used for the earlier date field (e.g., start date)

2 should be used for the later date field (e.g., end date)

Or with data-kilvish-date_name

Use data-kilvish-date_name to show user-friendly error messages instead of raw identifiers like EMP_1.

Age Validation Using data-kilvish-age
Use this attribute to validate age from a plain or field.

Attribute: data-kilvish-age="value" or data-kilvish-age="min_max"

Usage Patterns: data-kilvish-age="18" → Requires the user to be exactly 18 years old.

data-kilvish-age="18_60" → Accepts only ages between 18 and 60 (inclusive).

If the attribute is omitted, it defaults to exactly 18.

Validation Behavior: Input must be a valid number.

Field is cleared and error message shown if:

Non-numeric value is entered.

Age is below or above the defined limits.

Notes:

The attributes should be added to input elements where validation is required.
These validation rules are handled client-side, so users will be notified immediately if they input invalid data.
Customize the validation behavior further as needed (e.g., setting up custom error messages).
Author: Vasu Birla kilvishbirla@gmail.com

You can include this script in your project via CDN:
<script src="https://cdn.jsdelivr.net/npm/kilvalidate@1.0.62/kilvish.min.js"></script>


# KilValidate (Kil Validation)
A lightweight, drop‑in **form validation** CDN for web apps. Validates text, number, email, phone, files, amounts, dates, grouped dates, and **passwords with strength meter + eye icon**—all via **data‑attributes**. No initialization required.

> **CDN (latest)**  
> ```html
> <script src="https://cdn.jsdelivr.net/npm/kilvalidate@1.0.62/kilvish.min.js"></script>
> ```

---

## Table of Contents
- [Why KilValidate](#why-kilvalidate)
- [Quick Start](#quick-start)
- [Global Behavior](#global-behavior)
- [Validation Attributes](#validation-attributes)
  - [Numbers](#numbers)
  - [Alphanumeric / Characters](#alphanumeric--characters)
  - [Files](#files)
  - [Amounts / Currency](#amounts--currency)
  - [Dates](#dates)
  - [Date Group (From/To)](#date-group-fromto)
  - [Age](#age)
  - [Password + Eye Icon](#password--eye-icon)
- [Notes](#notes)
- [Author](#author)

---

## Why KilValidate
- **Zero setup**: just add the CDN
- **Declarative**: use HTML `data-kilvish-*` attributes
- **UX friendly**: inline error slots, persistent labels/asterisks, no layout jumps
- **Robust**: works with Bootstrap `.input-group`, Select2, and dynamic DOM

---

## Quick Start
Add the CDN and then add attributes to your inputs. Raw HTML below will render as live inputs on your website.

### Minimal form
<form id="demo-minimal" style="max-width:520px;padding:12px;border:1px solid #e5e7eb;border-radius:10px">
  <label class="form-label" for="username">Username</label>
  <input class="form-control" id="username" name="username" data-kilvish-char="mix" required placeholder="john_doe123">
  <br>
  <label class="form-label" for="contact">Phone</label>
  <input class="form-control" id="contact" name="contact" type="tel" required placeholder="+1 555 123 4567">
  <br>
  <label class="form-label" for="pwd">Password</label>
  <input class="form-control" id="pwd" name="password" type="password" data-kilvish-password="12_64" data-kileye-show="toggle" data-kileye-color="#005555" required placeholder="Strong password">
  <br>
  <button type="submit" class="btn btn-primary">Submit</button>
</form>

---

## Global Behavior
- Required fields get a red asterisk automatically.
- Errors render **under** the correct control (incl. `.input-group` and Select2).
- Password **strength meter + rule list** render **below** the field.
- Phone (`type="tel"` or `data-kilvish-tel`) avoids false positives (country code only).

---

## Validation Attributes

### Numbers
#### Numbers only
- **Attribute:** `data-kilvish-num="yes"`  
- Ensures only digits.

<form style="max-width:520px">
  <label for="numonly">Numbers Only</label>
  <input id="numonly" class="form-control" data-kilvish-num="yes" required placeholder="123456">
</form>

#### Numbers with length limits
- **Attribute:** `data-kilvish-num="_7_20"`  
- Only digits, length **7–20**.

<form style="max-width:520px">
  <label for="numlen">Numbers (7–20)</label>
  <input id="numlen" class="form-control" data-kilvish-num="_7_20" required placeholder="9876543">
</form>

---

### Alphanumeric / Characters
#### Mix (letters+numbers)
- **Attribute:** `data-kilvish-char="mix"`

<form style="max-width:520px">
  <label for="uname">Username (letters & numbers)</label>
  <input id="uname" class="form-control" data-kilvish-char="mix" required placeholder="john123">
</form>

#### Mix with specific specials
- **Attribute:** `data-kilvish-char="mix_%_$"`

<form style="max-width:520px">
  <label for="mixspec">Username (allow %, _, $)</label>
  <input id="mixspec" class="form-control" data-kilvish-char="mix_%_$" required placeholder="john_doe%">
</form>

#### Address‑friendly (space, dash, comma)
- **Attribute:** `data-kilvish-char="mix_ ,-_”`

<form style="max-width:520px">
  <label for="addr">Address</label>
  <input id="addr" class="form-control" data-kilvish-char="mix_ ,-_" required placeholder="221B Baker Street, London">
</form>

#### Letters only
- **Attribute:** `data-kilvish-char="Yes"`

<form style="max-width:520px">
  <label for="fname">First Name (letters only)</label>
  <input id="fname" class="form-control" data-kilvish-char="Yes" required placeholder="John">
</form>

#### Letters + specific specials
- **Attribute:** `data-kilvish-char="Yes_%_$"`

<form style="max-width:520px">
  <label for="brand">Brand (letters + %,_,$)</label>
  <input id="brand" class="form-control" data-kilvish-char="Yes_%_$" required placeholder="ACME_Pro%">
</form>

---

### Files
Use `data-kilvish-file` on `<input type="file">`.

- `image` (default): images only  
- `image_MIN_MAX`: min/max count (e.g., `image_1_3`)  
- `doc`: PDF, Word, Excel  
- `doc_MIN_MAX` (e.g., `doc_1_4`)  
- `pdf`: only PDF  
- `pdf_MIN_MAX`  
- `mix`: images + docs  
- `only_pdf_image`: PDFs + images  
- `only_doc_image`: DOC‑related + images

<form style="max-width:520px">
  <label for="fileimg">Images (1–3)</label>
  <input id="fileimg" class="form-control" type="file" data-kilvish-file="image_1_3" multiple>
</form>

<form style="max-width:520px">
  <label for="filedoc">Documents (1–4)</label>
  <input id="filedoc" class="form-control" type="file" data-kilvish-file="doc_1_4" multiple>
</form>

---

### Amounts / Currency
Use `data-kilvish-amount="CUR[_MIN_MAX]"`

- `USD` → formats to 2 decimals (e.g., `2` → `2.00`).  
- `USD_200_1000` → min/max enforced with inline messages.

<form style="max-width:520px">
  <label for="amt1">Amount (USD)</label>
  <input id="amt1" class="form-control" data-kilvish-amount="USD" placeholder="25 or 25.50">
</form>

<form style="max-width:520px">
  <label for="amt2">Amount (USD 200–1000)</label>
  <input id="amt2" class="form-control" data-kilvish-amount="USD_200_1000" placeholder="250">
</form>

---

### Dates
Attach `data-kilvish-date` to `<input type="date">` or `<input type="month">`.

- Age window: `_18_60` (between 18 and 60)
- **Future**: `future`, `today_future`, `30_days_future`, `2_years_future`, `2_years_after`
- **Past**: `past`, `10_years_past`, `2_years_before`
- **Ranges**: `Between_2000_2010`, `from_2023`, `till_2025`
- **Specific**: `not_today`, `weekday`, `weekend`, `first_of_month`, `last_of_month`, `exact_21`

<form style="max-width:520px">
  <label for="dob">DOB (18–60)</label>
  <input id="dob" class="form-control" type="date" data-kilvish-date="_18_60" required>
</form>

<form style="max-width:520px">
  <label for="future">Future date (next 30 days)</label>
  <input id="future" class="form-control" type="date" data-kilvish-date="30_days_future">
</form>

<form style="max-width:520px">
  <label for="wk">Weekday only</label>
  <input id="wk" class="form-control" type="date" data-kilvish-date="weekday">
</form>

> `leap_year` & combined multi‑conditions like `future_weekday` are **reserved** / not implemented yet.

---

### Date Group (From/To)
Link two fields so **From ≤ To** (or months).

- **Format:** `data-kilvish-dategroup="EMP_1"` and `data-kilvish-dategroup="EMP_2"`  
- Optional labels: `data-kilvish-date_name="From"` / `"To"`

<form style="max-width:520px">
  <div style="display:grid;grid-template-columns:1fr 1fr;gap:10px">
    <div>
      <label for="empFrom">Employment From</label>
      <input id="empFrom" class="form-control" type="month" data-kilvish-dategroup="EMP_1" data-kilvish-date_name="From" required>
    </div>
    <div>
      <label for="empTo">Employment To</label>
      <input id="empTo" class="form-control" type="month" data-kilvish-dategroup="EMP_2" data-kilvish-date_name="To" required>
    </div>
  </div>
</form>

---

### Age
Validate a plain age number.

- **Attribute:** `data-kilvish-age="value"` → exact age  
- **Attribute:** `data-kilvish-age="min_max"` → range

<form style="max-width:520px">
  <label for="ageExact">Exact age 18</label>
  <input id="ageExact" class="form-control" name="age" data-kilvish-age="18" placeholder="18">
</form>

<form style="max-width:520px">
  <label for="ageRange">Age 18–60</label>
  <input id="ageRange" class="form-control" name="age" data-kilvish-age="18_60" placeholder="e.g., 25">
</form>

---

## Password + Eye Icon

### Length & composition
- `data-kilvish-password="MIN_MAX"` – requires:
  - at least one lowercase, one uppercase, one digit, one special character
  - **no sequential runs** like `1234` or `abcd`
- Example: `data-kilvish-password="8_20"` ⇒ min 8, max 20.

### Eye icon (show/hide)
An eye icon is auto-injected at the end of every password field and stays inside the input (works with/without `.input-group`).

**Attributes**
- `data-kileye-show` — behavior:
  - `hold` *(default if omitted)*: press & hold to show; release/blur to hide
  - `toggle`: click to show/hide
  - `fix`: start visible; click to hide/show (no holding needed)
- `data-kileye-initial` — `on` | `off` *(default `off`; `fix` forces visible)*
- `data-kileye-color` — icon color (e.g., `#005555`)
- `data-kileye-false` — disable auto eye for this field

<form style="max-width:520px">
  <label for="pass1">Password (toggle eye)</label>
  <input id="pass1" class="form-control" type="password" data-kilvish-password="12_64" data-kileye-show="toggle" data-kileye-color="#005555" placeholder="Strong password">
</form>

<form style="max-width:520px">
  <label for="pass2">Password (fixed visible)</label>
  <input id="pass2" class="form-control" type="password" data-kilvish-password="12_64" data-kileye-show="fix" placeholder="Visible until you click eye">
</form>

<form style="max-width:520px">
  <label for="pass3">Confirm Password (hold)</label>
  <div class="input-group">
    <span class="input-group-text"><i class="ti ti-key"></i></span>
    <input id="pass3" class="form-control" type="password" data-kilvish-password="8_20" placeholder="Re-enter password">
  </div>
</form>

> The eye stays fixed inside the field. The strength bar remains visible below it, and the detailed rule list only appears while the password field is focused and has input.

---

## Notes
- Works with plain HTML or frameworks (EJS/Blade/etc.).
- Error slots are **persistent nodes** (no layout shift).  
- Add `data-ignore-kilvish="Yes"` to opt a field out of realtime checks.
- Required stars are normalized & auto‑deduped.

---

## Author
**Vasu Birla (Kilvish)**  
<kilvishbirla@gmail.com>


