Showing posts with label validator. Show all posts
Showing posts with label validator. Show all posts

Saturday, March 31, 2012

text box validation

I am using html text box, and the text area in my asp.net applicatioon c# rather than using the web form "text bpxes"

I then put a validator the typical one that VS.net provides and a web form submit

the validator makes sure that the text boses are fill...but when I hit submit nothing happens even when I fill the boxes ... I can see that the page is not even going back to the server

any ideas

WashingtonHi,

please provide the code that doesn't work out for you and be sure to use the apropriate tags (view post 98605).

On the other hand, I don't think it's possible to set theControlToValidate Property of a normal html textbox that isn't registered as a htmlcontrol (with the attribute runat="server").

Grz, Kris.
There is a bug in the client-side scripting for ASP.NET 1.1 SP1. Please see this thread for a solution:http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=739537

Wednesday, March 28, 2012

text box, command button and required field Validator

there is one text box, command button and one required
field validator control on a web form.
i want user to enter the data in text box i.e it is
mandatory field. so i had used required validator for
this purpose. all works perfectly it gave me the
message that please insert the data etc. but the
problem is that after that i want focus to be put back
on the control. [ please give me the solution keeping
in mind that there could be many such controls on the
form and i want to set focus on respective text box if
user doesn't enter the value for mandatory fiels ]If you want focus back on the textbox, you're in for a lot of work. Its not hard to put focus on the control using javascript, that's easy enough.

The problem stems from what you later ammend to your question (there could be many such controls). Ok... so if there's only one control, that control gets the focus. But if there are five, the fifth one will get focus (because each will apply focus, but the last one to attempt to do so will be the one that wins). And if the last control gets focus, what's the point really - you want it to be user friendly, and the user is going to want to start at the top, not at the bottom of the page.

So you now have a problem - how do you get focus on the first control on what could be a possible list of included controls. For that - you need a way to store the collection of the controls, and some code to determine which is the top-most (first rendered) control that flunked validation and requires focus.

You will need to tip-toe through the server-client architecture, using a combination of code-behind and javascript to do so.

If you wish to explore it further - you best describe more on what your control is (you mention a textbox, validator, and a button - button for each control or one button on the entire page?)