I use the following function to clear the value of input fields onfocus and reset them back to the original value if left empty.
The problem is now I am trying to serialize a form that contains radio buttons, and the value is always empty,
How can I modify this so it doesn’t clear the value of input radio buttons?
<script type="text/javascript">
jQuery.fn.resetDV = function() {
function _clearDV() {
var _$ = $(this);
if ( _$.val() == this.defaultValue ) { _$.val(''); }
};
function _resetDV() {
var _$ = $(this);
if ( _$.val() == '' ) { _$.val(this.defaultValue); }
};
return this.click(_clearDV).focus(_clearDV).blur(_resetDV);
}
$(function() {
$('input').resetDV();
});
</script>