CustomValidator ClientValidationFunction OnServerValidate Confusion

L

labogart

I have a form that has a textbox and a CustomValidator on it where I
need to perform some validation on both the client and also on the
server. I have a button on the form that saves the data. If I change
nothing in the field and hit the Save button, then Client side
validation occurs, the page does a postback and then the server side
validation occurs. If I change the data in the textfield, however,
and hit the save button then only the client side validation occurs,
the page does NOT postback and the server side validation does not
occur. At this point, I have the logic set so that it isn't really
even doing any validation (just setting IsValid = true) and it is
still doing this. Anyone have any idea what I am doing wrong?

<asp:TextBox ID="txtEmailAddress" MaxLength="255" runat="server"
Width="400px" CssClass="controlText" />

I have a customer validator set up as follows:

<asp:CustomValidator ID="CustomValidator1"
ClientValidationFunction="ClientSideValidate"
OnServerValidate="ServerValidation" EnableClientScript="true"
runat="server" ErrorMessage="Some Error Message"
ControlToValidate="txtEmailAddress" />

Client side Valdiation is as follows:
function ClientSideValidate(source, args)
{
//perform some validation
args.IsValid = true;

}

Server side Validation logic is as follows:
Sub ServerValidation(ByVal source As Object, ByVal args As
ServerValidateEventArgs)

'Perform some validation logic
args.IsValid = True

End Sub

Form has a button on it to save:

<asp:LinkButton ID="lnkSave" runat="server" ><img src="images/
save.jpg" class="imgButton" alt="Save" /></asp:LinkButton>


AutoEventWireup="false"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top