开发者

How does one disable the success message once the requied field message is shown?

I have a form with two text boxes. Once I enter the data and click the save button, I get a message in label: indicating that it saved successfully.

Then I show th开发者_如何学Pythone form again, but when I click on the save button, I get a message telling me that it cannot be blank "as textbox value is empty this time" from the required field validator.

But I am still showing the message "data saved successfully," which should not happen.

How do I solve this issue?

Thank you.


You need to set ValidationGroup on your textboxes, requiredfieldvalidators, and buttons to the same value. This will prevent (theoretically) the saving of blank values when the validators fire.

HOWEVER, do server-side validation too! The above is easy to sidestep.


Off the the top of my head, my suggestion would be to add an "OnClientClick" event your save button that calls out to a script which hides the "success" message client-side. I'm not sure if there is a way to trigger client-side code when client-side validation fails - without using a CustomValidator, but I could be wrong.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜