Solved

jquery datepicker -- on multiple fields

Posted on 2013-06-25
2
382 Views
Last Modified: 2013-07-11
How can I do something like
 $("#CreateDate" || "AuthorizedDate").datepicker({....
so can merge the below two
<script type="text/javascript">
sections into one ?
-----------------------------------------------------------------------------------------------------------
Create.cshtml
 <div class="editor-label">
            @Html.LabelFor(model => model.AuthorizedBy)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.AuthorizedBy)
            @Html.ValidationMessageFor(model => model.AuthorizedBy)
        </div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/jqueryui")
    @Styles.Render("~/Content/themes/base/css")

       <script type="text/javascript">
           $(document).ready(function () {
               $("#CreateDate").datepicker({
                   changeMonth: true,
                   changeYear: true
               });
           });
    </script>

           <script type="text/javascript">
               $(document).ready(function () {
                   $("#AuthorizedDate").datepicker({
                       changeMonth: true,
                       changeYear: true
                   });
               });
    </script>
0
Comment
Question by:finance_teacher
2 Comments
 
LVL 58

Assisted Solution

by:Gary
Gary earned 250 total points
ID: 39276284
Normal format for jquery is

 $("#CreateDate,#AuthorizedDate").datepicker({....

have never tried it with the datepicker tho, so may not work
0
 
LVL 4

Accepted Solution

by:
ScorchD earned 250 total points
ID: 39276435
Just use a class, then you can have as many as you need and automated.
$( ".datepicker" ).datepicker({ 

Open in new window

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now