Date Box Code

From FeMR Wiki
Jump to navigation Jump to search

ASP

JAVA SCRIPT

DATE WITH BUTTON

             $("[id$=txtDOB]").datepicker({
                 formatDate: "mm/dd/yy",
                 changeMonth: true,
                 changeYear: true,
                 maxDate: new Date,
                 constrainInput: false
             });
             $('#btnTodayDate').on('click', function () {
                 $('#txtDOB').datepicker('setDate', new Date());
             });
    

TIME WITH BUTTON

             
             $('#txtTime').timepicker({
                 showOn: 'button',
                 timeFormat: 'HHmm',
                 dynamic: false,
                 dropdown: true,
                 scrollbar: true,
                 buttonImageOnly: true,
                 constrainInput: false,
                 buttonImage: 'images/calendar.jpg'
             });
             $('#btnTimeNow').on('click', function () {
                 $('#txtTime').timepicker('setTime', new Date());
             });
 

DIVs FOR BUTTONS

Example 1-Working

                <div class="formRow">
                    <div class="col-Label150">
                        <label>DATE:</label>
                    </div>
                    <div class="col-Text125">
                        <asp:TextBox ID="txtSignatureDate" runat="server" CssClass="smallTextBox" />
                    </div>
                    <div class="InputBtnDateTime" runat="server" id="DivDate1" visible="true">
                       <input type="button" id="btnSignatureDate" value="Today's Date" runat="server"/>
                    </div>
                </div>
 

Example 2-Needs fixing

INSERT JUST AFTER THE TEXTBOX IN THE col-Text125 DIV THE ID for the Div and the button name must be unique

Only add buttons for dates and times that are today or now situations

DATE

                  <div class="InputBtnDateTime" runat="server" id="DivDate" visible="true">
                    <input type="button" id="btnTodayDate" onclick="TimeNow();" value="Today's Date" runat="server"/>
                  </div>
 

TIME

                  <div class="InputBtnDateTime" runat="server" id="DivTime" visible="true">
                    <input type="button" id="btnTimeNow" onclick="TimeNow();" value="Time Now" runat="server"/>
                  </div>
 

Combination Date/Time/Time on a single line

This is not 100% working, buttons need to be wrapped in a div that can be hidden. Below would hide the text field AND button.

                <div class="formRow">
                    <div class="col-Label">
                        <label>Date</label>
                    </div>
                    <div class="col-Text225" id="DivDate1" visible="true">
                        <asp:TextBox ID="txtFormDate" runat="server" CssClass="smallTextBox" />
                        <input type="button" id="btnFormDate" value="Today's Date" runat="server"/>  
                    </div>                  
                    <div class="col-Label100">
                        <label>SANE Called</label>
                    </div>
                    <div class="col-Text200" id="DivTime1" visible="true">
                        <asp:TextBox ID="txtSANECalled" runat="server" CssClass="smallTextBox" />
                        <input type="button" id="btnSANECalled" onclick="TimeNow();" value="Time Now" runat="server"/>
                    </div>                  
                    <div class="col-Label100">
                       <label>SANE Arrived</label>
                    </div>
                    <div class="col-Text200" id="DivTime2" visible="true">
                       <asp:TextBox ID="txtSANEArrived" runat="server" CssClass="smallTextBox" />
                       <input type="button" id="btnSANEArrived" onclick="TimeNow();" value="Time Now" runat="server"/>
                    </div>
                </div>
 

VB

DISABLED FIELDS

Make sure to add any button's to disabled fields.

DivDate.visible = false
DivTime.visible = false