RequiredFieldvalidator displays error too early

P

Preben Zacho

Hi there

I have a RequiredFieldValidator that displays the text "Required field" for
a textbox. The problem is, that the text "Required field" is displayed
BEFORE the user presses the button to accept the form. Why does this occure?
Must be some setting I've missed, cause in other forms it works as it
should, where the text is not displayed until the user click the accept
button.

My textbox and validator looks like this:

<asp:TextBox ID="tbFirstName" runat="server"
Width="204px"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqFirstNameUser"
runat="server" ControlToValidate="tbFirstName"
Enabled="True" ErrorMessage="Required field"
Display="Dynamic">
</asp:RequiredFieldValidator>
 
M

Mansi Shah

HI Preben,

You can chceck it by setting "AutoPostBack" property of textbox to
"true", if it can help your coding logic..


Regards,
Mansi Shah.
 
N

N

I will rather check if there is already a control on the page that is
causing auto post back.
 
P

Preben Zacho

Well, I have another control in the form where AutoPostBack="True" (a text
box for searching).

Exactly when is this type of validation executed? And how do I then override
it, so the text is not written before the accept button is triggered?
 
J

john123

Why not set the ValidationGroup property of the textbox so the validation occurs only when the according button is pressed?
 

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,905
Latest member
Kristy_Poole

Latest Threads

Top