0

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?

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Your code didn't initially work for me because the Repeater tag isn't generated as part of the markup when rendered in the browser, so I wrapped the Repeater control into a DIV. Then your code worked!! Thanks alot!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.