开发者

why RequiredFieldValidator control does not work after adding OnClientClick event for submit button?

开发者 https://www.devze.com 2023-03-24 11:04 出处:网络
I use .net RequiredFieldValidator control for those required fields validation, but I also need to verify fields using regular expression,and some other logic, so I also added OnClientClick event func

I use .net RequiredFieldValidator control for those required fields validation, but I also need to verify fields using regular expression,and some other logic, so I also added OnClientClick event function to the submit button. But I found after addin开发者_JAVA技巧g the OnClientClick event, all requiredfieldvalidator validation events are not fired after clicking submit button. Why? if it is the mechanism, how can I use both of them?


I've run into the same problem in the past. I haven't dug into the why, but I've called the Page_ClientValidate('ValidationGroup') javascript function directly in my OnClientClick event.

For example:

OnClientClick="if(Page_ClientValidate('Zip')) DoSomething();"
0

精彩评论

暂无评论...
验证码 换一张
取 消