Solved

JavaScript - ignore error and continue page load?

Posted on 2015-01-13
3
344 Views
Last Modified: 2015-03-22
Hi,
I am using http://trentrichardson.com/examples/timepicker/ in a contact form and receive the following error in IE 8.0 which stops the contact form from loading.

SCRIPT5007: Unable to set property 'parseDateTime' of undefined or null reference
File: jquery-ui-timepicker-addon.js, Line: 1125, Column: 2

	/*
	* Public Utility to parse date and time
	*/
	$.datepicker.parseDateTime = function (dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
		var parseRes = parseDateTimeInternal(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings);
		if (parseRes.timeObj) {
			var t = parseRes.timeObj;
			parseRes.date.setHours(t.hour, t.minute, t.second, t.millisec);
			parseRes.date.setMicroseconds(t.microsec);
		}

		return parseRes.date;
	};

Open in new window

     


Is there anyway to ignore the error and just continue with the form load without the date time picker functionality?

<script type="text/javascript">			
	
	$(document).ready(function () {

		$('#Preferred_Date_Time').datetimepicker({ 
        dateFormat: 'dd/mm/yy',
        minDate: new Date(<?php echo "$minDateY, $minDateM, $minDateD"; ?>),
        maxDate: new Date(<?php echo "$maxDateY, $maxDateM, $maxDateD"; ?>),
        showOn: "both", 
		timeFormat: 'hh:mm tt',
        buttonImage: "/images/calendar.gif", 
        buttonImageOnly: true 
      }); 
		
	});
</script>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.11.0/jquery-ui.min.js"></script>
<script src="/jquery_ui/development-bundle/ui/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="/ScriptLibrary/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="/ScriptLibrary/jquery.bvalidator.js"></script>
<link rel="stylesheet" href="/jquery_ui/development-bundle/themes/base/jquery.ui.all.css">

<div class="inputname">Preferred Date and Time:</div>
<div class="inputfield">
<input  name="form[Preferred_Date_Time]" type="text" class="formborder" id="Preferred_Date_Time" value="<?php echo $_SESSION['Preferred_Date_Time']; ?>" />
</div>

Open in new window

0
Comment
Question by:sabecs
3 Comments
 
LVL 10

Assisted Solution

by:Jeffrey Dake
Jeffrey Dake earned 200 total points
ID: 40548266
Have you tried moving your script lower in the Dom. Ie might not be loading the library before calling your function. Try putting the document.ready function script after your form.
0
 

Author Comment

by:sabecs
ID: 40548306
It works fine in most browsers, just need it to work or not cause an error in IE 8.0 as that is what the client is seeing?
0
 
LVL 42

Accepted Solution

by:
Rob Jurd, EE MVE earned 300 total points
ID: 40652467
You need to put your code last.  You just had your script tags in the wrong order

<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.11.0/jquery-ui.min.js"></script>
<script src="/jquery_ui/development-bundle/ui/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="/ScriptLibrary/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="/ScriptLibrary/jquery.bvalidator.js"></script>
<link rel="stylesheet" href="/jquery_ui/development-bundle/themes/base/jquery.ui.all.css">
<script type="text/javascript">			
	
	$(document).ready(function () {

		$('#Preferred_Date_Time').datetimepicker({ 
        dateFormat: 'dd/mm/yy',
        minDate: new Date(<?php echo "$minDateY, $minDateM, $minDateD"; ?>),
        maxDate: new Date(<?php echo "$maxDateY, $maxDateM, $maxDateD"; ?>),
        showOn: "both", 
		timeFormat: 'hh:mm tt',
        buttonImage: "/images/calendar.gif", 
        buttonImageOnly: true 
      }); 
		
	});
</script>


<div class="inputname">Preferred Date and Time:</div>
<div class="inputfield">
<input  name="form[Preferred_Date_Time]" type="text" class="formborder" id="Preferred_Date_Time" value="<?php echo $_SESSION['Preferred_Date_Time']; ?>" />
</div>

Open in new window

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
This article discusses how to create an extensible mechanism for linked drop downs.
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)

816 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

10 Experts available now in Live!

Get 1:1 Help Now