And why is it needed, please explain very "chewed."
3 answers
I myself began to understand recently and I can tell you that validation is a rather necessary thing, and I would even say necessary. Validation is done so that the left side does not come from the client side. For example, an empty string or invalid characters for the password. Example: a login form containing a line for entering a name and password. You validate these 2 textboxes. Suppose a user left these two textboxes empty or filled out only one of them. Validators for these fields will not allow sending him a request to the server with this data (in my example it is an empty line). Or the user has entered Cyrillic characters in the password field or some other data that the server or client can skorit. Thus validators will allow you to cut off the initially incorrect data. I understand it so.
- I mean the ASP.NET validator, as I understand it, it runs on the server, since it is a step in the life cycle of the aspx page. It was written in the article that it is needed so that malicious users cannot collect information about the site using scripts. How? - Max Dumchikov
The main feature of ASP.NET validators is that validation is performed on the client, without sending a request to the server. CustomValidator defaults to sending a request to the server, but it can be configured to run on the client (by giving it a javascript function that checks the entered value).
Further the integral result of validation is available through the property Page.IsValid.
Validators allow you to define declaratively
- What the user filled in the required fields
- That the data entered by the user fall into the desired range
- That the lines entered by the user have the desired format
- Any checks written by hand.
As far as I remember, all the results of validation are placed in a special control, which will be located in one place.
- I mean the ASP.NET validator, as I understand it, it runs on the server, since it is a step in the life cycle of the aspx page. It was written in the article that it is needed so that malicious users cannot collect information about the site using scripts. How? - Max Dumchikov
- The code that forms the javascript function, which checks the value entered by the user, is executed on the server. But this function itself before sending the request to the server is performed on the client. As for protection against intruders, then the validators will most likely not allow postback to be done until the page is full. But this so-so protection is rather an aid. Still, the main purpose of validators is usability. Although, in principle, of course, with the help of a validator, you can, for example, make a captcha. - Modus
In a word, the validator checks whether the user entered the data correctly when registering on a particular site or when entering the mail ...