Solved

JavaScript - ignore error and continue page load?

Posted on 2015-01-13
3
375 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 43

Accepted Solution

by:
Rob 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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)
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…

749 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