Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/khaouitiabdelhakim/form-validation-using-jquery
This is a simple HTML form validation script using jQuery. It validates the input fields for name, email, and password.
https://github.com/khaouitiabdelhakim/form-validation-using-jquery
css form-validation html jquery js
Last synced: 18 days ago
JSON representation
This is a simple HTML form validation script using jQuery. It validates the input fields for name, email, and password.
- Host: GitHub
- URL: https://github.com/khaouitiabdelhakim/form-validation-using-jquery
- Owner: khaouitiabdelhakim
- Created: 2024-05-08T22:14:26.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-05-08T22:14:39.000Z (6 months ago)
- Last Synced: 2024-10-10T12:45:13.871Z (about 1 month ago)
- Topics: css, form-validation, html, jquery, js
- Language: JavaScript
- Homepage: https://khaouitiapps.vercel.app
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Form Validation using jQuery
This is a simple HTML form validation script using jQuery. It validates the input fields for name, email, and password.
## Usage
1. Include jQuery library in your HTML file.
```html```
2. Copy and paste the provided JavaScript code into your HTML file or link it externally.
3. Create your HTML form with appropriate input fields and error placeholders.
```htmlName:
Email:
Password:
```
4. Customize error messages and validation rules as needed.
## Explanation
- The script uses jQuery to select the form element with the id `myForm` and listens for the `submit` event.
- When the form is submitted, it retrieves the values of name, email, and password fields.
- Error messages are initially reset to empty.
- It validates each field:
- Name: Checks if it's empty.
- Email: Checks if it's empty and validates its format using a regular expression.
- Password: Checks if it's empty and ensures it's at least 6 characters long.
- If any validation fails, corresponding error messages are displayed, and the form submission is prevented.
- The `isValidEmail` function is used to validate the email format using a regular expression.