HTML5 provides an easy to use form validation. There is no need to write complex JavaScript functions to validate form data.
Enter a date after 1990-01-01: <input type="date" name="birthday" min="1990-01-01" /> amount (between 1 and 5): <input type="number" name="amount" min="1" max="5" />