C sharp validating

by  |  21-Dec-2019 15:11

In that case you are following "Tell, Don't Ask" rule and also "Single Responsibility Principle" Good Luck I would create a method for changing the name that contains the validation logic.

I have some code that checks and makes sure that when the users enters in the field an integer from 1 - 10 has to be input.

Regular Expression Validator Control A regular expression is a powerful pattern matching language that can be used to identify simple and complex characters sequence that would otherwise require writing code to perform.

Using Regular Expression Validator server control, you can check a user's input based on a pattern that you define using a regular expression. These expressions can be phone number, email address, zip code and many more. Simply set the Validation Expression property to any type of expression you want and it will validate it.

Although if the users takes focus of the field, the "bad" data (such as "fdgfdg") is still left in the field.

Community Discussion