Tuesday, July 1, 2014

autocomplete - Remove user entered or update data on page refresh.

Situation
On real world we often repopulate user's previously saved data and ask them to update these details.
For example a Profile Page. On here some time user may try to reload the page after altered some data
on form, to get his/her original previous data(which means the data came from server). But browser does not act as he/she thinking. Browser will catch the form data and repopulate what he enter last time, not original data.

Solution
To avoid this we can use a html attribute called autocomplete. Simply set this attribute to false on your form tag.

Example 1:

<form name="profile" id="profile" method="post" action="profile_action" autocomplete="off">

We can use for a particular inputs only, as like below.


Example 2:

<input type="text" name="email" id="email" autocomplete="off" />

Note: By default autocomplete set to on for all.

No comments:

Post a Comment

Learn JavaScript - String and its methods - 16

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>String and it's methods - JS&l...