Total Page Preview:   000000000920

What is regular expression validator in ASP.NET in English and Hindi

 

 

Regular expression validator inASP.NET in English

A regular expression validator is a validation control in ASP.NET that allows you to validate user input based on a specified regular expression pattern. The regular expression pattern is used to define a set of rules that the user's input must match in order to be considered valid.
Here is an example of how to use a regular expression validator in ASP.NET:
1-First, add a regular expression validator control to your ASP.NET page. You can do this by adding the following code to your page's markup:
 
 
In this example, the regular expression validator control is given an ID of "MyRegexValidator". The ControlToValidate property is set to the ID of the textbox control that you want to validate (in this case, "MyTextBox"). The ErrorMessage property is set to the error message that will be displayed if the user's input is invalid. Finally, the ValidationExpression property is set to the regular expression pattern that the user's input must match in order to be considered valid (in this case, the pattern is "\d{5}", which means that the input must consist of exactly 5 digits).
2-Next, add a textbox control to your page that you want to validate. You can do this by adding the following code to your page's markup:
 
 
3-Finally, add a submit button to your page that the user can click to submit the form. You can do this by adding the following code to your page's markup:
 
When the user clicks the submit button, the regular expression validator control will automatically validate the input in the textbox control based on the regular expression pattern that you specified. If the input is invalid, the error message that you specified will be displayed next to the textbox control. If the input is valid, the form will be submitted normally.
 
 
 
Regular expression validator inASP.NET in Hindi
Regular Expression Validator ek validation control hai ASP.NET mein jo aapke dwara specify kiye gaye ek regular expression pattern ke anusaar user input ko validate karta hai. Regular expression pattern ka upyog user input ke liye ek niyam set ko define karne ke liye kiya jata hai, jisse user input valid maana jata hai.
Yaha ek ASP.NET mein Regular Expression Validator ka upyog karne ka udahran hai:
1-Sabse pahle, apne ASP.NET page mein ek Regular Expression Validator control ko add karein. Aap iska upyog apne page ke markup mein nimn code ko add karke kar sakte hain:
 
Is udahran mein, Regular Expression Validator control ko "MyRegexValidator" ID di gayi hai. ControlToValidate property ko textbox control ka ID diya jata hai jo aap validate karna chahte hain (is udahran mein, "MyTextBox"). ErrorMessage property mein error message di jati hai jo display kiya jayega agar user ka input invalid hai. Ant mein, ValidationExpression property mein regular expression pattern diya jata hai jo user input ke saath match karna hoga taki wah valid maana ja sake (is udahran mein, pattern "\d{5}" diya gaya hai, jo yah kahta hai ki input exact 5 digits hone chahiye).
 
2-Agla kadam yah hai ki, apne page mein textbox control ko add karen jisko aap validate karna chahte hain. Aap iska upyog apne page ke markup mein nimn code ko add karke kar sakte hain:

3-Ant mein, apne page mein submit button ko add karen jise user form submit karne ke liye click kar sakta hai. Aap iska upyog apne page ke markup mein nimn code ko add karke kar sakte hain:
 
Jab user submit button par click karta hai, Regular Expression Validator control automatic tarike se textbox control mein input ko validate karta hai aapke dwara specify kiye gaye regular expression pattern ke anusaar. Agar input invalid hai, to error message jo aapne specify kiya hai, woh textbox control ke sath hi display kiya jayega. Agar input valid hai, to form normally submit hoga.
 
 
 
 
 

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: