0

The date picker doesn't show up even though i use

  <input type="date" name="dob" required>  

Additional information that might help you help me : It is in a JSP file I'm using tomcat v7.0 I need to validate the date without using JavaScript?

I tried using text for input and setting a specified format but then how can I add range there? (min max and dynamic for February issues?)

Can this issue be addressed by using combobox? How can I change value options of one combo box depending on the other? (Date options dependent on month and/or year)

Any help is highly appreciated.

P.S. Since it is a part of a registration form, I have been advised against using JavaScript validation (as it can be disabled)

Edit : I guess I'll go with a regular expression. I found one here, the second answer to this question : Regular Expression to match valid dates

  • About your P.S. : even if JS validation can be disabled, you must validate any input on the server side. Never trust what's coming from the client side. A request can be forged and there will be no JS validation at all. – sjahan Apr 06 '18 at 07:53
  • @sjahan is it okay if I use regular expressions instead or can they be bypassed as well? – user8029928 Apr 06 '18 at 09:42
  • the important matter is to perform the validation server-side: in the side you own. On the client side, use can always disable the validation or forge an HTTP request. Using a regex is about how you validate: answer is: you totally can use regex to validate a date pattern :) – sjahan Apr 06 '18 at 11:27

1 Answers1

1

The date picker doesn't show up

It does when I test it. Perhaps you are using a browser which does not support it.

I tried using text for input and setting a specified format but then how can I add range there?

If by "format" you mean a pattern, then you would need a complex regular expression that had multiple parts.

e.g. 0 followed by 1-9, or 1 followed by 0-9, or 2 followed by 0-8 followed by / followed by 02 followed by (leap year logic).

It wouldn't be short or pretty.

Regular expressions do not lend themselves to describing the format of dates.

That said, see this question.

Can this issue be addressed by using combobox?

You can't have a combobox in HTML without using JavaScript, which you ruled out.

If you mean "a collection of select elements" then that would be "dropdown menus" not "a combobox".

You could use those, but there's no good way to stop people entering dates like the 31st of February.

How can I change value options of one combo box depending on the other?

Only with JavaScript, which you ruled out.


Since it is a part of a registration form, I have been advised against using JavaScript validation (as it can be disabled)

You shouldn't depend on JavaScript for input validation because it can be bypassed… but that is true of any client-side input validation you might implement.

Client-side input checking is useful because it can give users rapid feedback if they make a mistake and enter data which doesn't make sense.

You need to accompany it with server-side input checking in order to prevent bad data being inserted into your system deliberately.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • 1. I am trying to run it on eclipse itself and using tomcat. it is a jsp page. it doesn't show up here. 2. Yes, I did realise that was the way to go but was very confused about the options and limitations, found a better one on another link more suited to my format requirements, thanks! 3. Oh. 4. Oh. 5. Does the client side input validation bypass also include that of patterns on HTML5? Cause I'm using that.. do I still need to validate it on the server? Thanks a lot for the information though. – user8029928 Apr 06 '18 at 10:01