i want to list all form elements with their properties with jquery , i write this code , it works for element index 0 in form , but for other elements page will refresh and … !
here is my code :
$(document).ready(function(){
$("form#registerForm").submit(function(){
var allInputs = $("form#registerForm :input");
$.each(allInputs, function(index, field) {
$("#res").append(index + " :: " + field + "<br />");
$.each(field, function(pIndex, pValue) {
$("#res").append(pIndex + " :: " + pValue + "<br />");
});
});
return false;
});
});
thanks for your help 🙂
It is very likely that an error occurs in your method, causing the
return falsestatement to never be reached.To avoid such problems, use
event.preventDefault()at the beginning of yoursubmithandler.