Web Form Validation

A

Arpan

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
 
P

Peter Blum

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: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

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
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top