2011-01-17 33 views

Respuesta

12

Puede obtener current date in JavaScript:

var now = new Date(); 

Si está utilizando jQuery DatePicker se puede aplicar en cualquier campo de texto así:

$('input.youTextFieldClass').datepicker({ dateFormat: 'mm/dd/yy', 
            changeMonth: true, 
            changeYear: true, 
            yearRange: '-70:+10', 
            constrainInput: false, 
            duration: '', 
            gotoCurrent: true}); 

If you want to set current date in textfields as page load:

$("input.youTextFieldClass").datepicker('setDate', new Date()); 
+3

Lanza un nombre de etiqueta en ese selector y se ejecutará más rápido. Reemplaza ''.youTextFieldClass'' con'' input.youTextFieldClass''. – chprpipr

2

puede encontrar la muestra here.

<input type="text" id="datepicker"> 
$("#datepicker").datepicker({dateFormat:"dd M yy"}).datepicker("setDate",new Date()); 
Cuestiones relacionadas