Ievgen
Ievgen

Reputation: 4443

asp.net RequiredFieldValidator with custom control

I have custom control with asp textbox inside.

And i need to Validate by RequiredFieldValidator my custom control on CLIENT side.

I added attribute to custom control class:

[ValidationProperty("Text")]
    public class WatermarkTextBox : System.Web.UI.UserControl
{
}

It looks like working but it always make submit to server. How can i check it only on client side?

Upvotes: 2

Views: 3137

Answers (1)

TheGeekYouNeed
TheGeekYouNeed

Reputation: 7539

You need to use a CustomValidator like this

<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ValidateCheckBox"
ErrorMessage="Please enter something.">

ClientValidationFunction is the name of your javascript function

Upvotes: 3

Related Questions