function clearForm(form){// iterate over all of the inputs for the form// element that was passed in
$(':input', form).each(function(){var type =this.type;var tag =this.tagName.toLowerCase();// normalize case// it's ok to reset the value attr of text inputs,// password inputs, and textareasif(type =='text'|| type =='password'|| tag =='textarea')this.value="";// checkboxes and radios need to have their checked state cleared// but should *not* have their 'value' changedelseif(type =='checkbox'|| type =='radio')this.checked=false;// select elements need to have their 'selectedIndex' property set to -1// (this works for both single and multiple select elements)elseif(tag =='select')this.selectedIndex=-1;});};
//change event on password1 field to prompt new input
$('#password1').change(function(){//dynamically create new input and insert after password1
$("#password1").append("<input type='text' name='password2' id='password2' />");});