Y Tools

y-validate v4.4

Lightweight & High-Performance Form Validation Library

Documentation & Usage

Installation
<script src="yvalidate.js?lang=en"></script>
Use the lang=en parameter for English error messages.
Required Field
class="required"
Ensures the field is not empty.
Required (WP CF7 Compatible)
class="wpcf7-validates-as-required" WordPress
Native support for Contact Form 7 classes.
Email Validation
type="email" or class="email"
Checks for a valid email format.
Israeli Mobile Validation
class="cell"
Checks for Israeli format (05X-XXXXXXX).
Password Confirmation
class="password-confirm"
Add this class to both password fields to ensure they match.
Submit Button Loader
class="y-has-loader"
Add this class to the submit button to enable the automatic loading animation upon valid form submission.
Useful JS API
// Manual validation check
let isValid = y_validate_form( element );

// Add custom error message
y_add_error_msg( field, 'Your custom message' );

// Remove error message
y_remove_error_msg( field );

// Blur callback function
function y_blur_after_validate( field ) { ... }
Smart AJAX Loader
// Automatically stops the loader when your AJAX request (Fetch or XHR) is completed.

// Optional manual override:
y_hide_loader( form_element );
Requires adding the y-has-loader class to the submit button. Prevents double-submissions automatically.

Live Demo