Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 26, 2013 11:05 PM by Lesthad_mk
Feb 26, 2013 04:34 AM|LINK
Let me explain what I'm doing. I have a form with some fields that are mark as required. I've been using a
requiredFieldValidator and when the user click on the button which contian the
ValidationGroup property to be executed it works OK. It displayed in a
window alert those fields that are missing.
Now, what's the problem? Well, the thing is that there are some validation that need to be perform in the client side. So, I added the
OnClientClick property to the same button which contain the ValidationGroup. And here is where I have been having some details. The JS function that is executed on the OnClientClick return a boolean value. This is with the porpouse
to execute the server side method of that button when the validations are OK. And again it works OK. Buut, the problem is that the alert window for the ValidationGroup is not dispalyed.
So, my question would be. Could I use both the ValidationGroup and the OnclientClick properties to coexits for the same control (a button)?
I hope you can help me
Feb 26, 2013 05:12 AM|LINK
change OnClientClick attribute as below.... assuming the name of function which is called for OnClientClick is "CustomValidate()"
<asp:Button id="btnSave" runat="server" ValidationGrouup="something" OnClientClick="if(Page_ClientValidate()) CustomValidate();" .../>
hope this helps...
Feb 26, 2013 11:05 PM|LINK
Thanks for your help. I tried the approch your posted and it works fine when you only have one ValidationGroup on your page. However, when the page have more than one ValidationGroup it fires all them.
I fixed my problem just like this: OnClientClick = "CustomValidate();"
Notice, that I'm not using the return. I mean: OnclientClick = "return CustomValidate();"
I don't undesrtand very well why this fixed it because in some other codes I have the return. Well, but it works ;-)
Hope this helps