How to set default current date using jquery mobile? -


can please tell me how set default date on text field.actually have 1 button on click pop screen display in there date field show current date on date.

  <div data-role="popup" id="caseinformationscreen" data-close-btn="none"  data-overlay-theme="a" data-dismissible="false">                 <div data-role="header" data-theme="b" >                      <a href="#" data-role="button" data-corners="false" id="cancel">cancel</a>                     <h1>case information</h1>                     <a href="#" data-role="button" data-corners="false" id="addbutton">add</a>                 </div>                  <div data-role="content">                     <div><img src="img/documents.png"/></div>                     <div data-role="fieldcontain">                         <label for="text-12" style="text-align:top;margin-left: 0px;">case name:</label>                         <input name="text-12" id="text-12" value="" type="text" class="casename_h" autocorrect="off">                     </div>                     <div data-role="fieldcontain">                         <label for="casedate" style="text-align:left;margin-left: 0px;" >case date:</label>                         <input name="casedate" id="casedate" value="" type="date" class="casedate_h" >                            <!--input name="mydate2" id="mydate2" type="date" data-role="datebox" class="casedate_h" data-options='{"mode": "calbox","usenewstyle":true,"zindex":1200}'/-->                     </div>                     <div data-role="fieldcontain">                         <label for="textarea-12">case notes :</label>                         <textarea cols="40" rows="8" name="textarea-12" id="text-12" class="casetextarea_h" autocorrect="off"></textarea>                     </div>                 </div>             </div> 

working example: http://jsfiddle.net/gajotres/ndc2b/

html :

<!doctype html> <html>     <head>         <title>jqm complex demo</title>         <meta http-equiv='content-type' content='text/html; charset=utf-8'/>         <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densitydpi=device-dpi"/>         <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />         <!--<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>-->         <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>         </head>     <body>         <div data-role="page" id="index">             <div data-theme="b" data-role="header">                 <h1>index page</h1>             </div>              <div data-role="content">                 <a href="#caseinformationscreen" data-rel="popup" data-role="button" data-inline="true" data-transition="pop">basic popup</a>                 <div data-role="popup" id="caseinformationscreen" data-close-btn="none"  data-overlay-theme="a" data-dismissible="false">                     <div data-role="header" data-theme="b" >                          <a href="#" data-role="button" data-corners="false" id="cancel">cancel</a>                         <h1>case information</h1>                         <a href="#" data-role="button" data-corners="false" id="addbutton">add</a>                     </div>                      <div data-role="content">                         <div><img src="img/documents.png"/></div>                         <div data-role="fieldcontain">                             <label for="text-12" style="text-align:top;margin-left: 0px;">case name:</label>                             <input name="text-12" id="text-12" value="" type="text" class="casename_h" autocorrect="off"/>                         </div>                         <div data-role="fieldcontain">                             <label for="casedate" style="text-align:left;margin-left: 0px;" >case date:</label>                             <input name="casedate" id="casedate" value="" type="date" class="casedate_h" />                          </div>                         <div data-role="fieldcontain">                             <label for="textarea-12">case notes :</label>                             <textarea cols="40" rows="8" name="textarea-12" id="text-12" class="casetextarea_h" autocorrect="off"></textarea>                         </div>                     </div>                 </div>                                 </div>         </div>         </body> </html>    

javascript:

$(document).on('pagebeforeshow', '#index', function(){      $(document).on( "popupafteropen", "#caseinformationscreen",function( event, ui ) {         var today = new date();            var dd = today.getdate();         var mm = today.getmonth()+1; //january 0!          var yyyy = today.getfullyear();              $('#casedate').val(dd + '-' + mm + '-' + yyyy);         });         }); 

Comments