Custom textbox validating user input in

As I mentioned before, information is passed to the validation function in the event object, and in the code we see that the member ‘value’ is used to communicate the current value of the field.The member ‘rc’ (or return code) is used to communicate back if the validation was successful or not.Furthermore, utilizing the control in other Web applications is as simple as copying over the custom control's assembly ( There are many situations in which we may want to limit the number of characters a user can enter into a form field.

Then we select the “Validate” tab to see the validation options: The default is that the field will not get validated.

(For more information on using Custom Validators be sure to read Using the Custom Validator Control.) Another option for providing custom validation is to create your own validation server control.

This approach is ideal to the Custom Validator approach if you know that you are going to be using this validation on multiple pages or in more than one project.

In the latter case, we set rc to false, and also display an error message.

When you play around with the function, you’ll notice that the validation function is only called when the focus leaves the field, so you have to click outside of the field to actually make that error message pop up.

There are other ways to highlight the field in question besides changing the text color, the border color or the fill color could be changed instead, or in addition, just make sure that you are not making the form impossible to read.

You must have an account to comment. Please register or login here!