Delete Unchanged Form Fields

function detectChanges(oForm){
var elements = oForm.elements;
for (i = 0; i < elements.length; i++) { field_type = elements[i].type.toLowerCase(); if (field_type == "text" || field_type == "textarea"){ if (elements[i].value == elements[i].defaultValue){ elements[i].value = ""; }}} return true; }

Would you prefer to have visitors not submit text they didn't bother to change from default on your form? Set the submit button to run the above javascript function onclick. It simply iterates through each element of your form, and for each "text" or "textarea" field that still has its default value, it clears the content out. The function returns "true" so the submit proceeds normally.

Useful for long forms that include a lot of optional fields and nobody wants to explicitly test each value in whatever accepts the submission. It's client-side, so nothing should be written to rely on these fields being blank, of course. Your mileage may vary.