RequiredFieldValidator requires user to click twice

流过昼夜 提交于 2019-11-30 13:52:00

This happens because the code that clears out the error message runs when the textbox loses focus. So what happens is:

  1. You enter text in the field
  2. You click on the button, which causes the onblur event to happen on the textbox, firing the code to check the field's value again and removing the error message
  3. Now there are no errors in validation, so clicking the button again submits the form.

When you press the tab key first (or basically do anything that takes the focus off the textbox), then that onblur script runs and clears out the error so that when you click the submit button it is ready to go.

I had the same issue with a CompareValidator and found the problem went away when I changed the Display property from Dynamic to Static. Hope that helps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!