Reputation: 8659
I'm using an ASP.NET Repeater control to create rows of textboxes. I'm able to capture the value of the textboxes, but I would like to validate that all the textboxes have a value inside.
Is this possible to do in jQuery?
Upvotes: 0
Views: 1377
Reputation: 72222
Sure it is.
$(".submit-button").click(function() {
$("class-or-id-of-repeater").find("input[type=text]").each(function() {
if($.trim($(this).val()) == '') {
alert("At least one textbox is empty");
$(this).focus(); // focus the element
}
})
});
If you create Dynamic Controls in ASP.NET, the textboxes will still be rendered on the page after the postback.
I haven't tested this using an UpdatePanel, it might break if you used one.
Upvotes: 4