I have this form that is using data-defaults and I need to be sure that they are cleared before submission. I have a jackhammer script that will do it, but I’m wondering if any of you would mind helping me finesse it.
The script below works and is perfectly fine if I want to write it for every input in the form (currently 8 with data defaults). I’ve tried selecting all of the inputs in the form with a few different approaches, but nothing seems to work. I imagine that there is a much smarter way to approach this than I am capable of, which is why I come here 🙂
$('#form_input_submit').click(function() {
if ($('#specific_input_id').val() == $('#specific_input_id').attr('data-default')) {
$('#specific_input_id').val('');
}
return true;
});
This will check all the input elements that have a default data element and clear those fields before submitting.