6

I have a checkout form that will display a pop-up survey to ask why they haven't started filling out the form after 5 seconds. However, I need to be able to check whether the user has actually entered data as opposed to data entered by the browser's auto-fill feature (any pre-populated data set in the markup I specifically ignore in the javascript or jQuery).

Right now my solution is to have the setTimeout run a function which checks a variable (true or false) that is set to false on a jQuery .focus or .change event on the input types (input, select, textarea). However, since the javascript may load after the user is able to use the form elements, I have to check whether the user has entered data before the survey pops up.

Is it possible to differentiate between user-inputted data and browser-inputted data if the javascript loads after the user has done anything to the form fields?

Xion
  • 20,785
  • 9
  • 48
  • 77
Davicus
  • 388
  • 3
  • 14
  • 2
    ...I wouldn't recommend pursuing this as a UI feature, this may be personal, but I'd be terribly put out if the web page started getting, or appeared to get, cranky with me because I wasn't filling out a form fast enough. It's an interesting question, though, and **+1** for that :) – David says reinstate Monica Jul 26 '11 at 20:02
  • 2
    I would say tie your function to the keypress event. as for if they type anything in before the js is loaded... it's kind of superfluous at that point considering your hands are tied anyhow. – Joseph Marikle Jul 26 '11 at 20:03
  • Instead of "why haven't you started" within 5 seconds, how about "What's taking you so long?" after a minute or so? – Marc B Jul 26 '11 at 20:14

3 Answers3

4

If you really want to tell browser not to autofill it at all, you could use autocomplete attribute, but this is unfortunately an invalid attribute and thus will not validate. If you really need your HTML to validate, you can use jQuery to do just that for you:

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

More discussion about autocomplete here

Community
  • 1
  • 1
Andreas Wong
  • 55,398
  • 19
  • 100
  • 120
1

What about .keyup event for form?

var isFilledByUser = false;
$("#input").keyup(function(){
    var isFilledByUser = true;
});
genesis
  • 48,512
  • 18
  • 91
  • 118
0

ok... this was mildly entertaining, but I definitely agree... this feature would be so annoying XD

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

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

Joseph Marikle
  • 68,672
  • 14
  • 103
  • 120