Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
My jquery code is :

XML
<script type="text/javascript" src="Scripts/jquery-1.4.2.min.js" >
    </script>

    <script type="text/javascript">
        $(function () {
            $('input:text:first').focus();
           
            var $inp = $('.cls');
            $inp.bind('keydown', function (e) {
               
                var key = e.which;
                if (key == 13) {

                    e.preventDefault();

                  
                    var nxtIdx = $inp.index(this) + 1;
                   
                    $(".cls:eq(" + nxtIdx + ")").focus();
                }
            });
        });

    </script>





if i want to add a date picker with it.how can i add?
Posted

1 solution

Please try is as below.

XML
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Datepicker - Default functionality</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script>
  $(function() {
    $( "#datepicker" ).datepicker();
  });
  </script>
</head>
<body>

<p>Date: <input type="text" id="datepicker"></p>


</body>
</html>

LIVE DEMO : JSFiddle

More info : Date Picker
 
Share this answer
 
v2
Comments
Dew Drops 25-Apr-14 12:36pm    
thanks for your reply,but when i add the above code on my project then the date picker is not working. how can i make it as working?
Sampath Lokuge 26-Apr-14 0:14am    
can you put your whole code snippet with related to the data picker ? This is very simple task.
Dew Drops 26-Apr-14 0:58am    
<script type="text/javascript" src="Scripts/jquery-1.4.2.min.js" >
</script>

<script type="text/javascript">
$(function () {
$('input:text:first').focus();

var $inp = $('.cls');
$inp.bind('keydown', function (e) {

var key = e.which;
if (key == 13) {

e.preventDefault();


var nxtIdx = $inp.index(this) + 1;

$(".cls:eq(" + nxtIdx + ")").focus();
}
});
});

$(function () {

$("[id$=txtDate]").datepicker({ changeMonth: true,

changeYear: true
});

});
</script>


and asp code is
<asp:TextBox ID="txtDate" runat="server" Width="193px" >



but i cant get date picker to the textbox
Sampath Lokuge 26-Apr-14 1:01am    
You have to add jquery UI also.Please check my answer.And try to use latest jquery versions rather than the very old ones which you use currently.
Dew Drops 26-Apr-14 2:18am    
i'm trying with your code,but its working when i dont add my another scipt. but when i add the above script,then its not working :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900