Javascript example
by bilbobaggins
HTML
<form>
<input type="checkbox">
<input type="text">
<input type="hidden">
<input type="password">
<input type="radio">
<input type="submit">
</form>
<div id="messages"></div>
JavaScript
var allInputs = $( ":input" );
var formChildren = $( "form > *" );
$( "#messages" ).text( "Found " + allInputs.length + " inputs and the form has " +
formChildren.length + " children." );
$( "form" ).submit(function( event ) {
event.preventDefault();
});