Your "return false" is making the function inside your "each" method return false, it isn't making the ValidateFields function return false. In the update below I set an isValid variable that is updated by the inner function in "each" and that variable is then returned from ValidateFields.
<script type="text/javascript">
function ValidateFields(id) {
var isValid = true;
$("#Rpt1").find("input[type=text]").each(function () {
if ($.trim($(this).val()) == '') {
alert("At least one textbox is empty");
$(this).focus();
isValid = false;
}
});
return isValid;
}
</script>
For multiple control types
function ValidateFields(id) {
var isValid = true;
$("#Rpt1").find("input[type=text], input[type=file], .Select1").each(function () {
var el = $(this);
switch (this.tagName.toLowerCase()) {
case "input":
if (el.val() == '') {
if(el.attr('type') == 'text')
alert("At least one textbox is empty");
else if(el.attr('type') == 'file')
alert("Select a file");
isValid = false;
}
break;
case "select":
if (el.val() == '0') {
alert("Select a value");
isValid = false;
}
break;
}
if (!isValid) {
return false;
}
});
return isValid;
}