Showing posts with label html5. Show all posts
Showing posts with label html5. Show all posts

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.

Wednesday, January 22, 2014

"data" attribute in HTML5 and JQuery

This is used for store a value(its may string, array or object) on a html element.


Setting "data":
<input type="text" id="city" data-info="Main City" />      // Setting via html.
$('#city').data('city', "Main City");                                      // Setting via JS.
$('#city').data('city', ["blue","green","red"]);                      // Store array. 
$('#city').data('city', {special:"River",issue:"Factory"});    // Store object.

Getting Data:
var detail=$('#city').data();

Note: Do not use capital letters on "data" attribute name. Its not working.

Learn JavaScript - String and its methods - 16

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