Im using this code for my inputs:
$(document).ready(function(){
$('.add-news').each( function () {
$(this).val($(this).attr('defaultValue'));
$(this).css({'color':'#686868' , 'font-size':'11px', 'font-weight':'bold'});
});
$('.add-news').focus(function(){
if ( $(this).val() == $(this).attr('defaultValue') ){
$(this).val('');
$(this).css({'color':'#686868' , 'font-size':'11px' ,'font-weight':'bold'});
}
});
$('.add-news').blur(function(){
if ($(this).val() == '' ){
$(this).val($(this).attr('defaultValue'));
$(this).css({'color':'#686868' , 'font-size':'11px', 'font-weight':'bold'});
}
});
});
But in post, It posts ‘defaultValue’ not $_POST[‘name’]. How can I avoid this?
Thanks in advance
Your fields have the default value if the user isn’t in the field, so naturally when you post the form, that’s what will get posted. How ’bout something like this:
Style:
JavaScript:
That submit handler at the end wipes out the values on any elements with the class flagging that they’re showing the default value.
(There I’ve also done the off-topic thing I mentioned in my comment on the question; if you don’t want that, just remove the vars and do a search-and-replace changing
$thisto$(this).)