Hello sujay_das, In addition to above cited points from @BenStephenson, please find below code which would really useful for you to capture the error messages when end-user fill the form and got error messages. Basically this code works out if your FORM built in iFrame other wise you can write the straight forward method to capture the anticipated values.
$('input[type=submit], a.button, #iframe input[type=submit]').bind('click', function (e) { setTimeout(function () { var errorMessages = []; $('div.error-msg p').each(function () { errorMessages.push($(this).text()); }); $('p.error').each(function () { errorMessages.push($(this).text()); }); $("#iframe").contents().find("p.error").each(function () { errorMessages.push($(this).text()); }); $("#iframe").contents().find("div.error-msg").each(function () { errorMessages.push($(this).text()); }); $("div.error-msg").each(function () { errorMessages.push($(this).text()); }); if (errorMessages.length > 0) { console.log("Error Message Found ", errorMessages); for (var i = 0, len = errorMessages.length; i < len; i++) { if (errorMessages[i].length > 1) { window.utag_data['cevent_id'] = "Error: " + errorMessages[i]; window.utag_data['event_parent'] = "Respective page title"; window.utag_data['event_type'] = "Respective Error msg"; utag.link(window.utag_data, null, [9]); } } } }, 4000); });
Note: This is example code which you should change based on your requirement. Hope it helps! Happy Learning!
... View more