Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

Automatic HTML Form Validation

HTML form validation can be handled automatically by the browser.

If a form field (such as fname) is empty, the required attribute will prevent the form from being submitted.

HTML Form Example

<form action=”/action_page.php” method=”post”>
  <input type=”text” name=”fname” required>
  <input type=”submit” value=”Submit”>
</form>

Data Validation

Data validation ensures that user input is accurate, clean, and meaningful.

Common validation tasks include:

  • Checking if the user has filled in all required fields
  • Verifying if the user has entered a valid date
  • Ensuring that text is not entered in numeric fields

The main goal of data validation is to ensure accurate user input using various methods and approaches.

Server-side validation happens on the server after submission, while client-side validation occurs in the browser before submission.