Forums

Error gvalidation.js when on IE8

ulimc 15 Jan, 2015
Hi,
my client has found a problem when using the form with IE8.
The form in IE8 submits without making the checks. All other browsers are ok.

The error fired is this: "Property or method not supported by the object" (gvalidation.js, row 122, char 6)

This is where the debugger stops. --> return $this.val().trim().match(GValidtaion.rules[$rule_parts[0]]);

Any help would be much appreciated.
Thank you.
GreyHead 16 Jan, 2015
Hi ulimc,

I have no idea but did look at the code. In my version the line you posted is line 102, line 122 is
	$.fn.show_gvalidate_error = function(rule){
I'm afraid that doesn't help me understand the error though.

Bob
walterbz 16 Jun, 2015
Hi there, same problem with validation on IE8.
All other browser are ok.
Error:

Message: Property or method not supported by the object
Line: 274
Char: 8
Code: 0
URI: mysite/libraries/cegcore/assets/gplugins/gvalidation/gvalidation.js
Joomla: 3.2.4
Chronoforms5 5.0.9

Thank You
GreyHead 17 Jun, 2015
Hi,

Fortunately IE8 only has six months of life left . . .

It looks as though trim() isn't supported until IE9. I found this StackOverFlow answer which has a solution, Putting this Code into a Load JavaScript action in the form On Load event seems to resolve the error.
if(typeof String.prototype.trim !== 'function') {
  String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, ''); 
  };
}

Bob
walterbz 23 Jun, 2015
1 Likes
Great Bob.
Just offered you a beer! ThankYou
Walter
jmwilska 25 Jun, 2015
Same problem with IE8.

Added the above code to the Load Javascript action. It removed the error and added the red asterisk's to the fields
but it's still possible to submit the form without the required fields in IE8.

Form: http://www.phpoy.fi/index.php/palaute

Juha-Matti
GreyHead 25 Jun, 2015
Hi Walter,

You have a JavaScript error on the page from the giosg.com iFrame - if you get that fixed I think that the validation will be OK.

Bob
jmwilska 25 Jun, 2015
Hi Bob,

I can't see the error. The Giosg Chat is called with this script in the head section of index.php:

<!-- giosg tag -->
<script>
(function(w, t, f) {
var s='script',o='_giosg',h='https://service.giosg.com',e,n;e=t.createElement(s);e.async=1;e.src=h+'/live/';
w[o]=w[o]||function(){(w[o]._e=w[o]._e||[]).push(arguments)};w[o]._c=f;w[o]._h=h;n=t.getElementsByTagName(s)[0];n.parentNode.insertBefore(e,n);
})(window,document,2420);
</script>
<!-- giosg tag -->

Is there an error in the script?

Juha-Matti
GreyHead 25 Jun, 2015
Hi jmwlska,

It seems to come and go - I no longer see it in Chrome but get the error again in IE when the form first loads - then it goes again.

The validation appears to work correctly checking with IE11 in IE8 mode.

Bob
jmwilska 25 Jun, 2015
I removed the giosg script entirely but no luck. So the error must be somewhere else.
I have an old PC with IE8 and it doesn't require the fields to be filled. I can submit an empty form.

I dont mind but the client keeps calling me and asking about it. Apparently there's still a lot of IE8 users out there.

God I hate IE!
GreyHead 25 Jun, 2015
Hi jmwlska,

I'd suggest that you add serverside validation - that will work in IE8 and stop false submissions.

Bob
jmwilska 09 Jul, 2015
Hi Bob,

Server Side Validation did the trick.

One slight problem. With IE8 the "You did not fill in all the fields" page seems to breakup the template css?
GreyHead 09 Jul, 2015
Hi Juha-Matti,

I don't have 'pure' IE8 any more - I checked with IE11 in IE8 mode and that looks OK. I see this message below the form: Nimi ja sähköpostiosoite ovat pakollisia tietoja, jotta voimme olla sinuun tarvittessa yhteydessä.

Bob
jmwilska 09 Jul, 2015
Hi Bob,

That's okay. I can live with it. Thanks for all the help.
mnunes 09 Sep, 2015
1 Likes
Today I remembered to test some forms (V5) in IE8 and ran into this problem.
As it has been mentioned, the problem is that IE8 (and below) doesn't support String.trim()

If we replace line 274 of /libraries/cegcore/assets/gplugins/gvalidation/gvalidation.js
by
return $.trim($(gval.element).val()).match($.gvalidation.rules[$rule_parts[0]]);

It seems to work fine. No undesired form submission.


MN
This topic is locked and no more replies can be posted.