Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

jquery datepicker -- on multiple fields

Posted on 2013-06-25
2
Medium Priority
?
400 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 1000 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 1000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses

886 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