Node.js examples for HTML:Form
Clear a form of all it's values
function clearForm(frmObj) { for (var i = 0; i < frmObj.length; i++) { var element = frmObj.elements[i]; if(element.type.indexOf("text") == 0 || element.type.indexOf("password") == 0) { element.value=""; } else if (element.type.indexOf("radio") == 0) { element.checked=false;// w ww .ja va 2 s. co m } else if (element.type.indexOf("checkbox") == 0) { element.checked = false; } else if (element.type.indexOf("select") == 0) { for(var j = 0; j < element.length ; j++) { element.options[j].selected=false; } element.options[0].selected=true; } } }