Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net RequiredFieldValidator with custom control

Tags:

c#

asp.net

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?

like image 495
Ievgen Avatar asked Nov 20 '25 18:11

Ievgen


1 Answers

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

like image 187
TheGeekYouNeed Avatar answered Nov 23 '25 08:11

TheGeekYouNeed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!