How to make a form with date field? (DD / MM / YYYY)

3

I am a beginner in Kohana and need to make a form with a date field. My form is this:

<?=form::open('controllerInscricao/index')?>
<?php echo form::select('TURMA_codturma', $TURMA_codturma); ?> <br><br>

<div>Matricula: <?=form::input('ALUNO_MATRICULA' );?></div>
<div>Data: </div>
<?php echo '<div'.HTML::attributes($attrs).'>'.$content.'</div>'; ?>
<?=form::submit('btn_submit', 'Salvar') ?>
<?=form::close()?>

How to make a txt field in DD / MM / YYYY format?

    
asked by anonymous 01.02.2015 / 23:37

2 answers

6

I recommend using datepicker + maskedinput. I use version 1.3.1 of maskedinput that runs on older IE.

Documentation links and downloads:

link

link

The code will look something like this:

<input type="text" id="data />

$.datepicker.setDefaults($.datepicker.regional['pt']);

$("#data").mask("99/99/9999");

$('#data').datepicker();

These two plugins will save you time in the matter of verifying that only numbers have been included in the plugin.

    
02.02.2015 / 19:19
3

I suggest using the plugin datepicker of jqueryui : link

Code sample:

// Cria-se um input padrão com um id para identificar ele
<diva>Data: <input type="text" id="datepicker"></div>

And add the script to the bottom of the page:

<script>
$(function() {
  // #datepicker é o seletor para o campo criado
  // datepicker() é o método do plugin que diz que aquele campo
  // deverá obedecer as regras de data
  $('#datepicker').datepicker();
});
</script>
    
02.02.2015 / 18:06