2011-01-17 13 views
6

मैं एक कैलेंडर प्लग-इन का उपयोग कर रहा हूं और मैं वर्तमान दिनांक को टेक्स्ट फ़ील्ड में पॉप्युलेट करना चाहता हूं। Jquery का उपयोग करके मैं यह कैसे कर सकता हूं?jquery का उपयोग कर वर्तमान दिनांक कैसे प्राप्त करें?

+5

क्या कैलेंडर प्लगइन? क्या आप हमें लिंक दिखा सकते हैं? – Reigel

उत्तर

12

आप current date in JavaScript प्राप्त कर सकते हैं:

$('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

उस चयनकर्ता पर एक टैग नाम फेंको और यह तेजी से चलाएगा। ''.youTextFieldClass' 'को' input.youTextFieldClass '' के साथ बदलें। – chprpipr

2

आप पा सकते हैं:

var now = new Date(); 

आप jQuery DatePicker उपयोग कर रहे हैं आप इस तरह किसी भी पाठ फ़ील्ड पर लागू कर सकते हैं नमूना here

<input type="text" id="datepicker"> 
$("#datepicker").datepicker({dateFormat:"dd M yy"}).datepicker("setDate",new Date()); 
संबंधित मुद्दे