Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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.
```html

Name:


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.