Google Chrome inserting datepicker into inputs

Asked

Viewed 155 times

1

I’m having trouble with tags <input> of the kind type="date", as shown below, when user uses Chrome (ie in Firefox works as expected).

<input name="dt_fim" id="dt_fim" type="date" placeholder="99/99/9999" value="<?=$dt_fim?>" maxlength="10" pattern="(0[1-9]|1[0-9]|2[0-9]|3[01])\/(0[1-9]|1[012])\/2[0-9]{3}" required>

Chrome discards the value="" when it receives an input-ready date, it returns in the wrong format when the user writes manually and adds an date Picker input I did not request.

Now, the obvious solution is to make the type text type="text", but according to HTML5 I could/should flag as date type type="date", because that is how it is.

Is there anything that I can do in my sources in order to fix or prevent this, in addition to setting input as text? This is my mistake?

2 answers

2


Actually it is correct only in Chrome, firefox does not support the input="date" and uses the fallback of input="text", if you do not want datepicker, use datepicker input="text" even

http://caniuse.com/#search=type%3D%22date%22

0

I had the same problem a long time ago, if you’re not in a hurry, you can use jquery to create calendar inputs.

  • In fact, that’s what I did. I changed the data inputs to type="text" and, as I already had both Jquery and a mask library in the project, I only had to write in Javascripst this link between the mask and the inputs. (Welcome to Stack Overflow)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.