Archive image

Posts Tagged ‘forms’

How to validate that two time ranges don’t overlap in JavaScript

I was working on a form for a timekeeping app, where a user is able to enter their time worked, as well as breaks taken.

There is no limit on the amount of breaks that may be taken, but one of the validation requirements is that no two breaks may overlap.

Here’s how I implemented this validation check.

Read more…

How to tell if a form has been submitted using PHP

Consider this scenario:

You have a form which submits to itself (e.g. a simple contact form). The first time it loads you don’t want to do anything other that render the form.

However, when a user hits “Submit”, you want to process whatever data you have received, then re-render the form, including (for example) error messages where appropriate.

Read more…