0

I have an input for Date of Birth, but I not quite sure what error I must show if the user enters a future date.

I already test it out with Invalid date of birth but it's confusing.

  • With particular states passing legislation lately to recognize citizenship of unborn babies, birth dates in the near future might become valid, also in childcare applications etc. where the expected data is birth or due date. – Crissov May 20 '19 at 21:04
2

In your question, you say it's an error "...if the user enters a future date." So, tell the user that's what happened.

Date of birth cannot be a future date.

| improve this answer | |
  • Thank you! Great insight. – luispa May 20 '19 at 18:11
  • Depending on your business, you can even generate a funny message like "Wowowow, hold on there, Marty McFly! Either you give us the blueprints for your time machine, or you have to enter a birthdate that's set in the past." – marvinpoo May 22 '19 at 10:06
1

Disable future dates in the calender input control.

| improve this answer | |
  • This seems to be the best solution. Why show error messages, if you can stop the user from making the error in the first place? – marvinpoo May 22 '19 at 10:04
  • Can you elaborate? Most birth date input fields won't (shouldn't) use calendar inputs, as those are best suited for nearby dates. In the input field, how would you be able to disable all future dates? – maxathousand May 22 '19 at 13:11
  • For this case, the date input it's not a calendar. It's a common masked input field. – luispa May 22 '19 at 14:46
  • @luispa - If it is not a Date control, then there are two solutions to restrict errors 1. follow ISO format (YYYY/MM/DD) and once the user types year beyond the current year, make the text box in red color. Even the same with Month and Date. 2. If you can prefill the current date which they can edit and don't allow beyond present dates by validating with the system date or online date. (This requires some JQuery / JavaScripinting - its a separate question you can ask). If you can provide the common masked input field with date control. – Rupesh Nath May 23 '19 at 15:21
  • @maxathousand - This is question you need to ask in different community (Stakeoverflow). This function is well know where you restrict beyond present date, even you can enable a range of dates as well. One of the site which shows good examples of date controls - flatpickr.js.org/examples. Hope this helps. – Rupesh Nath May 23 '19 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.