$(document).ready(function() {
$('#commentForm').submit(function(){
return $('input[type=text], textarea').each(function(index){
if($(this).attr('value') == ""){
alert(msgHash[$(this).attr('id')]);
return false;
}else{
if(!$(this).attr('value').match(validateHash[$(this).attr('id')])){
//Do nothing
alert(msgOnError[$(this).attr('id')]);
return false;
}
}
});
return true;
});
});
Here msgOnError, msgHash and msgHash are map that I use to get messages for each text box with particular ID Unfortunately each method does not return false to cancel submission of the form. What am I doing wrong ?? I am new to jQuery, Thanks