I have written the following recursive input validator and it works for me. Is there a better way to visit each dom element and check if it is an input field and validate it?
function formValidator(parent)
{
//base case no children
if( parent.children().length == 0)
return
//recurse through each childs' child
parent.children().each(function(){
formValidator($(this));
/**
* Work : check if this node is an input node
*/
if($(this).is("input"))
{
var type = $(this).attr('type');
if(type =="text")
//do work bro
}
});//end for each
}