Validating birthdate to be greater than 18 years
Field Validation Rule You can use a field validation rule to specify a criterion that all valid field values must meet.You should not have to specify the current field as a part of the rule unless you are using the field in a function.We were already using the j Query Validation plugin for the form validation method but it didn’t have a method for checking for a minimum age.The j Query Validation plugin makes client-side form validation easy.Number fields can be found in the Basic Fields section of the builder, while Date/Time fields are found in the Advanced Fields section: Set the first dropdown to be the Date/Time field added to the form and set the second dropdown to the Current Date. This should be the age (in years) that the submitter needs to be in order to submit the form.The third drop-down determines what value the result will be calculated as: days, months, or years. In this example, I want the submitter to be at least 21 years old.One idea I had was for validating whether a customer stored in the database is in fact old enough to be purchasing the games in their order, so I wrote a little PHP function to do just that.We ran across an interesting bug in our application recently: a user who was 18 years old exactly could not sign up for our service. It turns out, we had last deployed to production 7 days ago.
I use Gravity Forms for just about everything I do form-wise on the web, so of course I turned there first.Though it works fine, but code does not look very readable and performance (not measured accurately) can be also a downside.While working on a client project, we needed a way to ensure a user was at least 13 years old before submitting a form.This happened only in our production environment (not staging, development or test) and when we manually tested a number of dates, a user who was 18 years and 7 days old could sign up, but a user who was 18 years and 6 days old could not. We didn't see the problem in any other environments because they get restarted so frequently.If you like to offer an input field for the birthdate you have to add it on the forms field page.