How to use Asp.net regular expression
How to use regular expression in asp.net
Regular expression is a pattern matching standard (way ) for string parsing and replacement. That used on a wide range of platforms and programming (Application development) environments. Some time we can say that Regular expression is a way of Clint side validation. The short form of Regular Expression is regales. This reg form regular and exes from expressions.Regular expression in asp.net
•Use regular expressions for constrain input, apply format rules, and check lengths of string or input data.•Use the ASP.NET Regular Expression Validator control for constrain and validate input with given condition.
•Use the Regular Expression (regexes) class to constrain and validate client input data.
•knowledge common regular expressions that can be used to constrain input data in programming.
Example of regular expressions can be used to parse dates, url(universal resource locator) and email addresses, file type, log files, text, String, Numeric values, configuration files, command line switches or programming scripts.
Basically there are fallowing steps To validate a server control's input using a Regular Expression Validator are:-
1 .Add a Regular Expression Validator control in asp.net page.
2 .Set Validate Control (by using control ID).
3. Set the Validation Expression property with regular expression (validation conditions).
4. Set the Error Message property, for define the Error message to display if the validation fails.
Regular expression for Enter number only in Textbox :
ValidationGroup="ch"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
Control To Validate="Txtbox" ErrorMessage="You must enter a phone number in the form of (999) 999-9999."
ValidationExpression="^[\d\s\(\)\-]+$" ValidationGroup="ch"/>
Regular expression for URL validation
/((?:https?\:\/\/|www\.)(?:[-a-z0-9]+\.)*[-a-z0-9]+.*)/i^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$
Regular expression for ZIP code validation
^(\d{5}-\d{4}|\d{5}|\d{9})$|^([a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d)$Regular expression for Password Validation
(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$Regular expression for Non- negative integer validation
^\d+$Regular expression for Currency (non- negative) validation
^\d+(\.\d\d)?$Regular expression for Currency (positive or negative) validation
^(-)?\d+(\.\d\d)?$Regular expression for Phone Number Validation :
^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$Regular expression for Email Validation :
^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$Regular expression for Image format validation
<asp:RegularExpressionValidator ID="revImage" ControlToValidate="uplImage"
ValidationExpression="^.*\\.((j|J)(p|P)(e|E)?(g|G)|(g|G)(i|I)(f|F))$" Text=" ! Invalid image type" runat="server" />
Related Questions :
- building a multiple email regular expression for a regular expression validator on asp.net with c# Programming
- regular expression validation in asp.net
- Prevent Range Validator to show error message with regular expression validator in asp.net Parogramming
- in Asp.net Text with RegEx Validator not working
- Regex Help needed with field validation in asp.net
- Regex for required field in Asp?
- Validate date field in asp.net using validator control in Prograaming
Other Impotent Post:
- Use to countdown time for use to time limit : in asp.net
- Sending mail from web application by using gmail ID
- Display selected Date from data base into calendar
- how to get the First Sunday of the Given Month in Asp.net
- Limit Number of Characters in a TextArea using jQuery
- Get selected radio button values using JQuery
- How do you do html text encodes using JavaScript
- Example jQuery Validate on CheckBoxList using C#
- How do you do html text encodes using JavaScript
- Check Uncheck all html CheckBox controls using jQuery:
- Check Uncheck all asp.net CheckBox in asp.net using jQuery
- Example of jQuery Validate on Radiobuttonlist in Asp.Net using C#
- Validate ASP.Net RadioButtonList using JavaScript Example
- Example of jQuery Validate on Radiobuttonlist in Asp.Net using C#
- Cropping image using jQuery in asp.net
- Displaying the textbox value in javascript Messagebox
- Get selected radio button values using JQuery
- fill data into Dropdown list by using Jquery
- jQuery Crop Image in Asp.net using Jcrop jQuery
- Example jQuery Validate on CheckBoxList using C#
- Check Uncheck all asp.net CheckBox in asp.net using jQuery
- Check Uncheck all html CheckBox controls using jQuery:
- Asp.net CheckBoxList using jQuery.
- Get selected radio button values using JQuery.