skip to Main Content

I have an input type date like

<input type="date" />

I don’t want users to be able to change the date manually, but require them to use the button provided for.
So I did

<input type="date" onkeydown="return false"/>

No problem with Chrome but it don’t work with Fierfox.
Have you a solution pls ?

2

Answers


  1. you can just add readonly attribute:

    <input type="date" readonly />
    
    Login or Signup to reply.
  2. sorry, now i understand what do you want.
    you’re right onkeydown="return false" does not work on firefox because firefox does not care about the return of this function unlike other browsers (neither onkeyup).

    you can acheive what you want by prevent the user from focusing the input, like this:

    <input type="date" onclick="this.blur();" tabindex="-1">
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search