You'll want to use an onsubmit
handler on the form that does the same thing the onfocus
does: Clears the text out of the box if it's the default text. That way, the fields will be blank when they're submitted.
To do that, I'd put some structure in place to avoid duplicating code. Completely off the cuff:
var Placeholders = {
"field_5": "Telephone",
// ...and the other fields...
};
function clearFieldPlaceholder(field) {
var placeholder;
placeholder = Placeholders[field.name];
if (placeholder && field.value == placeholder) {
field.value = "";
}
}
function formSubmit(form) {
var index;
for (index = 0; index < form.elements.length; ++index) {
// You may want to filter here a bit, e.g., check if it's
// a text field
clearPlaceholder(form.elements[index]);
}
}
onfocus
for fields:
<input ... onfocus="clearPlaceholder(this);" ...>
onsubmit
for form:
<form ... onsubmit="formSubmit(this);" ...>