Total Page Preview:   000000000652

What is compare validator in ASP.NET in English and Hindi

 

Compare validator in ASP.NET in English

The CompareValidator control is an ASP.NET validation control that checks if the value entered in an input field matches another value or a control on the same page. It can be used to validate fields such as passwords, email addresses, and confirmation fields.
Here's an example of how to use the CompareValidator control to validate that the value entered in a password field matches the value entered in a confirmation field:

In this example, the Password TextBox and ConfirmPasswordTextBox are two text boxes used for entering a password and a confirmation password, respectively. The Password Required Field Validator is a required field validator that ensures that the user enters a value in the password field. The Password Compare Validator is a compare validator that checks if the value entered in the Confirm Password TextBox matches the value entered in the PasswordTextBox.
 
When the user submits the form, the CompareValidator control will check if the value entered in the ConfirmPasswordTextBox matches the value entered in the Password TextBox. If the values do not match, an error message will be displayed.
 
Note that the ControlToCompare property of the CompareValidator control specifies the ID of the control to compare against. In this case, it is set to the ID of the PasswordTextBox control. The ErrorMessage property specifies the error message to display if the validation fails.
 
 
 
Compare validator in ASP.NET in Hindi
 
CompareValidator control ek ASP.NET validation control hai jo input field mein enter kiya gaya value ko dusri value ya dusre control se match karne ke liye use kiya jata hai. Ye password, email address aur confirmation fields jaise fields ko validate karne ke liye istemal kiya ja sakta hai.
Yahan ek CompareValidator control ka istemal karte huye bataya gaya hai jo verify karega ki password field mein enter kiya gaya value confirmation field mein enter ki hui value se match karta hai ya nahi:
 
 
Is example mein, PasswordTextBox aur ConfirmPasswordTextBox dono text boxes hai jo password aur confirmation password ke liye istemal kiye jate hain. Password Required Field Validator ek required field validator hai jo yeh ensure karta hai ki user password field mein value enter kare. Password Compare Validator ek compare validator hai jo yeh verify karta hai ki Confirm Password TextBox mein enter ki gayi value Password TextBox mein enter ki gayi value ke saath match karti hai ya nahi.
Jab user form submit karta hai to CompareValidator control Confirm Password TextBox mein enter ki gayi value ko PasswordTextBox mein enter ki gayi value ke saath match karke verify karta hai. Agar values match nahi hoti hai to ek error message display kiya jata hai.
Dhyan rakhe ki CompareValidator control ke ControlToCompare property mein control ka ID specify kiya jata hai jisse compare karna hai. Is case mein, ye PasswordTextBox control ka ID hai. ErrorMessage property mein validation fail hone par display hone wala error message specify kiya jata hai.

 

 

 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: