How to determine if data on a form has been entered by a user or browser?

I have an extract form in which there will be a pop-up survey to ask why they did not start filling out the form after 5 seconds. However, I need to check if the user actually entered the data, and not the data entered by the browser autofill function (any pre-populated data set in markup that I specifically ignore in javascript or jQuery).

Currently my solution is for setTimeout to run a function that checks for a variable (true or false) that is set to false in the jQuery.focus or .change event for input types (input, selection, text area). However, since javascript can be loaded after the user can use the form elements, I have to check if the user entered the data before the poll pops up.

Is it possible to distinguish between user-entered data and data entered by the browser if javascript is loaded after the user has done something in the form fields?

+6
source share
3 answers

If you really want to tell the browser that it does not autocomplete it at all, you can use the autocomplete attribute, but this, unfortunately, is an invalid attribute and therefore will not be checked. If you really need HTML code to validate, you can use jQuery to do this:

$(your_form_selector).attr('autocomplete', 'off'); 

Learn more about autocomplete here.

+4
source

What is the .keyup event for a form?

 var isFilledByUser = false; $("#input").keyup(function(){ var isFilledByUser = true; }); 
+1
source

ok ... it was a little funny, but I definitely agree ... this feature will be so annoying XD

http://jsfiddle.net/NTvrN/1/

but there you go ... now enter, foo!

0
source

Source: https://habr.com/ru/post/893627/


All Articles