JavaScript can be used to validate HTML forms. For example, a function can check if a form field like the name field is empty and alert the user if it is. This function returns false to prevent form submission. The HTML form would call this validation function on submit. JavaScript validation ensures users fill out required fields correctly before their input is submitted.