By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,693 Members | 1,132 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,693 IT Pros & Developers. It's quick & easy.

Web Form Validation

P: n/a
I have a Web Form in my ASPX page which makes use of Web controls & incorporates validation controls. This is the code snippet that does the needful:

<form runat=server>
NAME:<asp:TextBox id="txtName" runat=server/>
<asp:RequiredFieldValidator ControlToValidate="txtName" ErrorMessage="Enter your name!" Display="Dynamic" runat=server/>

<%-- some other server controls here --%>

<asp:Button id="but1" Text="SUBMIT" OnClick="show" runat=server/>
</form>

Now IE 6.0 has the AutoComplete feature (i.e. if the letter "a" - without the quotes - is typed in a textbox, a list showing previous entries beginning with "a" comes up so that the user can select directly from that list without having to type the entire word again.

Next what I do is submit the Form leaving the textbox empty. As expected, the appropriate error message gets displayed & the Form doesn't get submitted. Now if I type something in the textbox & then make the textbox lose focus (maybe by going to the next control), the error message that was displayed earlier when the Submit button was clicked without any data,as expected, vanishes but if the data is entered in the textbox, not by typing, but by selecting one of the options shown in the AutoComplete list, then the error message doesn't disappear when the textbox loses focus; the error message remains as it is although the textbox is not empty!
Why this discrepancy? How do I get rid of such a behaviour?

Thanks,

Arpan
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Client-side validation hooks up to the textbox's onchange event to fire it
when the user makes a change.

Unfortunately, Autocomplete does not fire onchange. So it doesn't give
validation a chance to run. IMO, this is a flaw in IE.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Arpan" <ar******@hotmail.com> wrote in message
news:eS**************@TK2MSFTNGP11.phx.gbl...
I have a Web Form in my ASPX page which makes use of Web controls &
incorporates validation controls. This is the code snippet that does the
needful:

<form runat=server>
NAME:<asp:TextBox id="txtName" runat=server/>
<asp:RequiredFieldValidator ControlToValidate="txtName" ErrorMessage="Enter
your name!" Display="Dynamic" runat=server/>

<%-- some other server controls here --%>

<asp:Button id="but1" Text="SUBMIT" OnClick="show" runat=server/>
</form>

Now IE 6.0 has the AutoComplete feature (i.e. if the letter "a" - without
the quotes - is typed in a textbox, a list showing previous entries
beginning with "a" comes up so that the user can select directly from that
list without having to type the entire word again.

Next what I do is submit the Form leaving the textbox empty. As expected,
the appropriate error message gets displayed & the Form doesn't get
submitted. Now if I type something in the textbox & then make the textbox
lose focus (maybe by going to the next control), the error message that was
displayed earlier when the Submit button was clicked without any data,as
expected, vanishes but if the data is entered in the textbox, not by typing,
but by selecting one of the options shown in the AutoComplete list, then the
error message doesn't disappear when the textbox loses focus; the error
message remains as it is although the textbox is not empty!
Why this discrepancy? How do I get rid of such a behaviour?

Thanks,

Arpan
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.