");
},
//Default http error handling, note this function only applies to http errors not form processor errors, for that please override "handleErrors"
handleHttpErrors: function(jqXHR, textStatus, errorThrown) {
if(this.settings.region in submissionFailedErrors) {
this.$formErrorMessages.show().text(submissionFailedErrors[this.settings.region]);
} else {
this.$formErrorMessages.show().text(submissionFailedErrors['en_us']);
}
},
//Default error handling, note this function only applies to form processor errors, NOT http errors, for that please override "handleHttpErrors"
handleErrors: function(response) {
var formID = response.formID
var fields = response.data;
var errors = [];
for(var field in fields) {
if(fields.hasOwnProperty(field)) {
var datum = fields[field];
if(datum.status != 'SUCCESS') {
errors.push({ name: datum.name, value: datum.value, errors: datum.messages });
}
}
}
//Find and show outstanding errors
$.each(errors, function(index, error) {
if(error.errors.join) {
$('#'+formID+' .fp-field-error-' + error.name).show().html(error.errors.join('
'));
$('#'+formID+'_'+error.name).addClass('input-error');
}
$('#'+formID+' .fp-field-error-' + error.name).closest('.fp-container').addClass('fp-container--error');
});
//Show any form level errors that we might have
if(response.messages.length > 0) {
this.$formErrorMessages.show().html(response.messages.join('
'));
}
}
});
//Wire up the jquery plugin
$.fn[pluginName] = function(options) {
return this.each(function() {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName, new Plugin(this, options));
}
});
};
})( jQuery, window, document );
;(function ( $, window, document, undefined ) {
"use strict";
var pluginName = "addFormProcessorErrorElements",
defaults = { };
function Plugin(element, options) {
this.element = element;
this.$formElement = $(element);
this.settings = $.extend({}, defaults, options);
this._defaults = defaults;
this._name = pluginName;
this.init();
}
$.extend(Plugin.prototype, {
init: function () {
var that = this;
that.addMainFormError();
that.addFieldErrors();
}, addMainFormError: function() {
//removed for stylistic reasons
// this.$formElement.find('#fieldList').before('
');
}, addFieldErrors: function() {
var that = this;
this.$formElement.find('input[type=text], select').each(function() {
var $this= $(this);
var name = $(this).attr('name');
$this.after('
');
});
this.$formElement.find('input[type=checkbox]').each(function() {
var $this= $(this);
var name = $(this).attr('name');
var id = $(this).attr('id');
$this.next('label').after('
');
});
}
});
//Wire up the jquery plugin
$.fn[pluginName] = function(options) {
return this.each(function() {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName, new Plugin(this, options));
}
});
};
})( jQuery, window, document );
jQuery(document).ready(function($) {
var $form = $('#FP_20180810_GeForce_RTX2070_Notify').addFormProcessorErrorElements().formProcessor({
handleSuccess: function (data) {
$('#FP_20180810_GeForce_RTX2070_Notify').empty();
$("#success-msg").remove();
$("#success-msg2").remove();
//$('#FP_20180810_GeForce_RTX2070_Notify').append("
");
$('#FP_20180810_GeForce_RTX2070_Notify').append("
" + data.messages.join(". ") + "
");
try {
dtm_track('formSubmit',{formID:'FP_20180810_GeForce_RTX2070_Notify'});
}catch(e) {}
},
handleHttpErrors: function (jqXHR, textStatus, errorThrown) {
this.$formErrorMessages.show().text(textStatus);
}
});
});