0

I have a form (autocomplete='on') that contains a text input

<input type='text' name='code' />

When this form is submitted using $.ajaxSubmit() from jQuery Form Plugin, the value of the textbox is not getting cached by browsers.

Is it possible to somehow cache the values natively to a browser, so users can see their previous values when they start typing?

SkyFx
  • 186
  • 10

2 Answers2

0

At your first ajax call, make a cookie and store code into it, then in every other ajax calls, check if cookie(code) exist just print that value into your form field.

Here is a good tutorial for Javascript Cookies

zarpio
  • 10,380
  • 8
  • 58
  • 71
  • Well, I don't need to send anything to server, I just need a value to appear in a dropdown next time the user starts typing something in this textbox. It is certainly possible to implement custom autocomplete with values stored in local storage (or cookies), but browsers already do have a cache for text inputs, I wonder if and how it can be manipulated. – SkyFx Mar 13 '16 at 02:30
0

There is not a convenient way by which you can handle the process how the browsers handle autocomplete storage. You can use a workaround. For example: If you have a login form, you send the credentials using AJAX. If the credentials are incorrect, display an error message. Else login using AJAX and submit the form using Javascript. The form may be a fake one. Just handle the redirect in the submit page. That will store the credentials in autocomplete.

Deval Khandelwal
  • 3,458
  • 1
  • 27
  • 38