Regular expression for validating name in asp net

6854933580_2c8b688306_z

Regular Expression Regular Expressions are specially formatted strings for specifying patterns in text.

They can be useful during information validation, to ensure that data is in a specified format.

# 4- each time just one occurrence of underscore or dot is valid.

Ignore Pattern Whitespace)) else new Regex("^[a-z._] $", Regex Options.

Is Match(text, @" # Validate username with 5 constraints. # 1- only contains alphanumeric characters , underscore and dot.

# 2- underscore and dot can't be at the end or start of username, # 3- underscore and dot can't come next to each other. :[_.][A-Za-z0-9] )*$) # 5- number of characters must be between 8 to 20.

The following HTML Markup consists of a Text Box, a Button and a Regular Expression Validator to which I have applied the Regular Expression (Regex) to accept only Alphabets and Space as valid characters. Here Mudassar Ahmed Khan has give some examples of combination of Regular Expressions (Regex) along with ASP.

regular expression for validating name in asp net-10regular expression for validating name in asp net-66

To the Button a j Query click event handler is attached thus when the button is clicked, the Text Box text is validated against the Regular Expression (Regex) and if it contains character other than Alphabets or Space then an error message is displayed. Net Regular Expression Validator samples to validate Minimum and Maximum text Length and also different configurations like Alphanumeric with special characters, Alphanumeric, Alpha and Numeric configurations. The Drop Down List will be specified as Control Parameter in the Sql Data Source Filter Parameters, so that when a Value is selected in the Drop Down List it will filter the Grid View Records. :[abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKl MNOPQRSTUVWXYZ0123456789]))(?! :[abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKl MNOPQRSTUVWXYZ0123456789._]))(?! The code above calls the first Name Text Box's Focus method to place the cursor in the first Name Text Box..If there are no empty fields then the following code validates the first name by calling the static method Match of the Regex class, passing both the string to validate and the Regular Expression as arguments. This object contains a Success property that indicates whether a method Match's first argument matches the pattern specified by the Regular Expression in the second argument.Here Mudassar Ahmed Khan has explained the following three types of character length or count validations for ASP. Here Mudassar Ahmed Khan has explained with an example and attached sample code, how to filter Grid View records using Text Box in ASP. To accomplish the task I have made use of Sql Data Source with Filter Expression along with Filter Parameters to filter records and bind the ASP. The Text Box will be specified as Control Parameter in the Sql Data Source Filter Parameters, so that when text or value is entered in the Text Box and the Search Button is clicked, it will filter the Grid View Records based on Starts with LIKE Search.

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