Jim Jeffries
Jim Jeffries

Reputation: 10081

JQuery Datepicker not working

I am trying to get a date picker working and I am really struggling with my limited javascript knowledge. I have been basing this on this tutorial.

I have the following code:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>    
<script type="text/javascript" src="scripts/date.js"></script>    
<script type="text/javascript" src="scripts/jquery.datePicker.js"></script>    
<script type="text/javascript" charset="utf-8">    
 $(function()    
 {    
  $('.date-pick').datePicker().val(new Date().asString()).trigger('change');
 });    
</script>

...

<input name="oDate" id="oDate" class="date-pick" />

Any suggestions would be very much appreciated.

Upvotes: 2

Views: 13709

Answers (4)

ssug89
ssug89

Reputation: 249

Please check if browser java script is turned off

Upvotes: 0

Alpesh
Alpesh

Reputation: 5405

I have tried below configuration and it's working fine on my local host -

Browser Tested - Mozilla Firefox version 3.6.10

I have xampp package installed.

I am including the html file that i have used for testing -

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>    
<script type="text/javascript" src="date.js"></script>   
<script type="text/javascript" src="jquery.datePicker.js"></script>
<LINK REL=StyleSheet HREF="datePicker.css" TYPE="text/css" MEDIA=screen>    
<script type="text/javascript" charset="utf-8">    
 $(function()    
 {    
  $('.date-pick').datePicker().val(new Date().asString()).trigger('change');
  //$('.date-pick').dpSetEndDate('01/01/2010');
 });    
</script>

</head>
<body>
<input name="oDate" id="oDate" class="date-pick" />
</body>
</html> 

Upvotes: 2

leora
leora

Reputation: 196891

i would suggest you take a look at the regular jquery ui datepicker to get a standard out of the box datepicker working. Start by simply using the exact code you see here and then tweak (step by step) as necessary. There are tons of example for all different use cases and good documentation

Upvotes: 4

petsagouris
petsagouris

Reputation: 1763

I hope you have an input tag like so in your HTML body:

<input name="date" id="date" class="date-pick" />

Upvotes: 0

Related Questions