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

Question:

I'm new to 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?

Answer:

I recommend using datepicker + maskedinput. I use maskedinput version 1.3.1 which works on older IE.

Documentation and download links:

http://digitalbush.com/projects/masked-input-plugin/

http://jqueryui.com/datepicker/

The code will look something like this:

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

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

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

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

NOTE: These two plugins will save you time in checking if only numbers were included in the plugin.

Scroll to Top