?
Solved

JavaScript - ignore error and continue page load?

Posted on 2015-01-13
3
Medium Priority
?
432 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 800 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 1200 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
Suggested Courses

770 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