I have standard contact form in HTML:
<input type="text" class="text" value="" name="username" id="username" />
And to return values when an error is occured, I’m using localstorage:
$(document).ready(function() {
var item = window.localStorage.getItem('username');
$('input[name=username]').val(item);
$('input[name=username]').change(function() {
window.localStorage.setItem('username', $(this).val());
});
The problem is in Internet Explorer. When I open my page with the contact form for the first time all the fields have value named “NULL”. Is there a way for me to remove that?
Thanks
Check if the value is
nullbefore setting it using.val()?