Solved

JavaScript - ignore error and continue page load?

Posted on 2015-01-13
3
320 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
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…

708 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