Sunday, 15 January 2012

jquery - Activate Month dropdown only when Year is selected from dropdown in datepicker -


Please tell me to get this scenario.

I am using jquery datepicker. Now my requirement is that the user should be able to choose the year before the month and before the day. This is for the date of birth capturing. Please help me in this.

  $ ("datepicker", $ reference) .each (function () {var base option = {inline: true, date format: "dd-mm-yy", changing year: true , Change: true, show: but "button", button image: "img / calendar.gif", button image only: true, show mothafir year: true, button text: "pick date"}; var attr = $ (this ) .attr ("minimum"); if (attr! = Undefined) {baseOptions.minDate = attr; baseOptions.yearRange = "+0: +5";} atr = $ (this) .attr ("max"); If (atr! = Undefined) {baseOptions.maxDate = attr; baseOptions.yearRange = "-120: +0";} atr = $ (this) .attr ("setBirthdate"); if (attr = undefined) {var date = New date (date); Date.setFull Year (date.getFullYear () - 12) baseOptions.defaultDate = date;} option = {ON selection: function (date text, insta) {$ (this) .value (datetext). Trigger ('change'); $ ( Inst) .hide ();}}; $ (this) .data picture ($. Extension (base option, option); $ (this) .on ('click', function (e) {e.preventDefault () ;}) Datepicker ($ extension (baseOptions, options); As I said in my comment, I do not think that really is really. However, if you really need to work in this way, I use some like this and add a small CSS / jQuery to get this effect, though  

 $ (Function () {$ ('# date' (. '). $ (' Year '). Change (function () {$ (this) .Parent (' combodate '). (' Month ' ) Search ();}); $ ('.month'). Change (function () {$ (this) .Parent ('combodate') search ('d '). Show ();});});  
  .day {display: none;} .month {display: none;}  
  & lt; link href = "http: // vitalets Github.io/combodate/prettify/ Prettify-bootstrap.css "rel =" stylesheet "/> & lt; link href =" http://vitalets.github.io/combodate/bootstrap/css/bootstrap.css " Rel = "stylesheet" /> & Lt; Script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "http://vitalets.github.io/combodate/combodate.js" & gt; & Lt; / Script & gt; & Lt; Script src = "http://vitalets.github.io/combodate/momentjs/moment.min.2.5.0.js" & gt; & Lt; / Script & gt; & Lt; Input type = "text" id = "date" data-format = "DD-MM-YYYY" data-templates = "D MMM YYYY" name = "date" value = "" & gt;  


No comments:

Post a Comment