get all input fields of form in jquery code example

Example 1: jquery get all input name and values and submit

$("form").submit(function(){ return validateForm($(this)) });
function validateForm(form){
var retVal = true;
var re;
$.each(form.serializeArray(), function(i, field) {
  var input = $('input[name='+field.name+']');
  field.value = $.trim(field.value);
  switch(field.name){
    case "name" :
        and another cases...
      }
    })
 }

Example 2: how to get form all filed with properties in jquery

$(function(){
 $(':input','form').each(function(i, o){
    $('#op').append($(o).attr('custom') + ' value:' + $(o).val()+'<br/>');
 })
});