<script type="text/javascript"> $(document).ready(function(){ $("#Element_type").change(function () { if($('#Element_type').val()=='date'){ var now = new Date(); var dateToPrint = now.getFullYear() + '-' + ('0' + (now.getMonth() + 1)).slice(-2) + '-' + ('0' + now.getDate()).slice(-2) + ' ' + ('0' + (now.getHours())).slice(-2) + ':' + ('0' + now.getMinutes()).slice(-2) + ':' + ('0' + now.getSeconds()).slice(-2); $("#default_value").val(dateToPrint); } else{ $("#default_value").val('<{$default_value}>'); } }) }); </script>