Dealing with the Google Toolbar's autofill feature has been a constant frustration in my web development journey over the years. I have resorted to creating a timer control to monitor changes, as the developers overlooked firing change events on controls. This challenge becomes even more complex when dealing with nested repeaters and integrating it with an UpdatePanel.
Has anyone successfully found a way to prevent Google Toolbar from auto-filling form fields without having to rename the field to something irrelevant? (Note: The workaround doesn't apply to a 'State' dropdown, as it even detects field values).
It seems ironic that such a prominent company like Google missed this crucial oversight despite their reputation for intelligence.
Update: For those seeking a solution, if you are using ASP.net, one approach that worked for me is utilizing the server control "Timer" as a trigger for the UpdatePanel. It involves looping through and checking for changed values.
If you are limited to JavaScript or using another framework, the following function proved effective for monitoring state and zip code changes. The focusElement parameter is necessary due to changes occurring while hovering in a dropdown list:
function MonitorChanges(sStateDropdownID, sZipCodeID, sHiddenStateFieldId, sHiddenZipFieldId, bDoPostback) {
var state = $('#' + sStateDropdownID).val();
var zip = $('#' + sZipCodeID).val();
var hiddenstate = $('#' + sHiddenStateFieldId).val();
var hiddenzip = $('#' + sHiddenZipFieldId).val();
$('#' + sHiddenStateFieldId).val(state);
$('#' + sHiddenZipFieldId).val(zip);
var compareString = state + zip;
var compareHiddenString = hiddenstate + hiddenzip;
var focusElement = getElementWithFocus();
if (compareString != compareHiddenString && isShippingZip(zip)) {
bDoPostback = true
}
if (parseInt(focusElement.id.search('drpState')) == -1 && parseInt(focusElement.id.search('txtZip')) == -1 && bDoPostback) { bDoPostback = false; __doPostBack(sStateDropdownID, ''); }
var f = function() { MonitorChanges(sStateDropdownID, sZipCodeID, sHiddenStateFieldId, sHiddenZipFieldId, bDoPostback); }
setTimeout(f, 1000);
}