Remove input field options of type datetime-local

Asked

Viewed 1,361 times

1

I have an input field type datetime-local and I need it to be as clean as possible, without cleaning buttons or step and just displaying the date and time in this format: '12/12/2016 12:01', I would like to know how I can configure this field.

My code:

<input id="prevSolucao" data-bind="value: prevSolucao, enable: !semPrevisao()" placeholder="Previsão de solução" type="datetime-local" class="form-control" style="padding-left: 13px;" autocomplete="off">

Upshot:

inserir a descrição da imagem aqui

I would like to remove the side buttons and that the calendar is not displayed.

1 answer

1


With CSS - In Chrome

You can put the whole typing field (::-webkit-datetime-edit), as 100%, which hides the button:

input::-webkit-datetime-edit{
  min-width: 100%;
  width: 100%;
}
<input type="datetime-local">

Wearing a mask

Use a mask. In your case, as the functions of this field are not required, use a input[text] same. In the example I use the Jquery Mask

$('#date-field').mask("00/00/0000 00:00", {placeholder: "__/__/____ 00:00"});
input{
  margin: 10px;
  padding: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://igorescobar.github.io/jQuery-Mask-Plugin/js/jquery.mask.min.js"></script>
<label for="date-field">Datetime - local</label>
<br>
<input type="text" id="date-field">

  • The problem in this case is that the dates are not validated, for example, I can enter the following date '41/14/2016 25:98' invalid and the field will accept in good.

  • @Leandroj.S.Paiva, edited! See if it fits you.

  • That’s just what I needed, it’s validating perfectly. Thank you.

Browser other questions tagged

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