You are viewing limited content. For full access, please sign in.

Question

Question

Forms Java Functions in Microsoft Edge Not Working Properly

asked on November 18, 2019

Hi All,

This may be a bug, or I may be doing something incorrectly.  I have a form used to submit copy requests.  Occasionally we block dates for the copier's vacation.  If a person types a date, such as 01/03/2020, then the form converts it to 1/3/2020.  All fine and well, except, when that occurs, it doesn't spur the .change function in our JavaScript in Edge.  Further, the script works as intended in Chrome.

Ultimately we are only trying to prevent a person from selecting blocked dates for a request, and in the event they try to type a blocked date, they get an error message.  I am sure there are different validation methods to do this, but we like the script we have as it is easy to update.  I am unsure if this was always a problem as there have always been full dates (as in 10-10-2019 or 11-12-2013).

Here is the script:

$(function() {
  $(document).ready(function () {

    var array = ['2020-01-03','2020-01-06']; // Four digit year

    function checkDate(date) {
      var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
      return [ array.indexOf(string) == -1 ]
    }
    
    function checkField(input, inst) {
    	if ($(input).closest('li').hasClass('dueDate')) {
      		$(input).datepicker("option", {beforeShowDay: checkDate});
      	}
    }
    
  	$.datepicker.setDefaults( {beforeShow: checkField} );
    
    $('.dueDate input').on('change', function(event) {
      var value = event.currentTarget.value;
      if (value == '1/3/2020' || value == '1/6/2020'){
      	alert( "I will not be available this day, please select another Due Date." );
        event.currentTarget.value = '';
      }
    });

Thanks in advance!

0 0

Replies

replied on November 18, 2019

Looks like you have some syntax errors. Try removing Line 1 and finishing the wrapping on your $(document).ready() function. This should work: 

$(document).ready(function () {

	var array = ['2020-01-03', '2020-01-06']; // Four digit year

	function checkDate(date) {
		var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
		return [array.indexOf(string) == -1]
	}

	function checkField(input, inst) {
		if ($(input).closest('li').hasClass('dueDate')) {
			$(input).datepicker("option", { beforeShowDay: checkDate });
		}
	}

	$.datepicker.setDefaults({ beforeShow: checkField });

	$('.dueDate input').on('change', function (event) {
		var value = event.currentTarget.value;
		if (value == '1/3/2020' || value == '1/6/2020') {
			alert("I will not be available this day, please select another Due Date.");
			event.currentTarget.value = '';
		}
	})
});

 

0 0
replied on November 18, 2019

I appreciate the reply.  First, thanks for the syntax updates, but I should have been more clear.  This has a few other functions below, and also why I didn't have it closed. My bad.  However, the issue still stands.  I made a copy of the form, removed all other scripts and used the one you provided.  It greys the dates from the picker, and works as my original form does. Yet, if someone types 01/03/2020 using Edge, it will not return the error.  This same script works in chrome without issue.

0 0
replied on November 18, 2019

Very odd... It's behaving the same for me.

Interestingly, I had luck with getting it to work in Edge by adding a console.log() above the if statement in your on change callback...

datefield.PNG
datefield.PNG (43.76 KB)
0 0
replied on November 18, 2019

Can you share the script? when I put the console log there I get the same behavior as originally described, but i could easily be doing something wrong.  Also, when i type "01/03/2020" it doesnt even show an item in the log!  It does show when i simply type 1/3/2020.  To further compund this mystery, in chrome, when i type 01/03/2020 it shows in the log as 1/3/2020...

If adding the log the way you have fixes the issue, then i am more than happy to do so!  Thanks again!

 

0 0
replied on November 18, 2019

I want to throw out that this entire issue may be moot come January 15, 2020 when Edge switches to Chromium.

0 0
replied on November 18, 2019

That is interesting, but I wonder if Microsoft would change how its browser interprets the fields and their java functions.  I think it is strange that blur or change is not interpreted by Edge if forms modifies the data, while chrome does. 

Useful info, but I will still have this issue come January 3rd or 6th :D.  

0 0
replied on November 18, 2019

It likely would - Edge switching to Chromium should make it behave identically to Chrome in scenarios related to Javascript/HTML/CSS. One of the main goals of the switch :)

1 0
replied on November 19, 2019 Show version history

The new version of Edge uses Chromium's JavaScript engine, so it will behave almost exactly the same as Chrome; there may be a few minor differences that come up over time, but not nearly as many as with an entirely separate engine.

I've been running the Chromium version of Edge off-and-on since they opened the Dev channel and my Forms seem to behave the same in both browsers. In fact, some of the ones with a lot of fields actually seem to run smoother in Chromium Edge.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.