Validation for textbox ASP.Net

Referred URL - http://dotnetdots.wordpress.com/2013/04/24/textbox-validation-for-indian-pan-card-number-using-textbox-validating-event/

1) Textbox Validation For Indian Pan Card Number
RegularExpressionValidator Validate = new RegularExpressionValidator();

Validate.ControlToValidate = TXT_Currency_Value.ID;
Validate.ErrorMessage = " - * Enter valid number";
Validate.Display = ValidatorDisplay.Dynamic;
Validate.ValidationExpression = (@"^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}?$";

2) Validating an e-mail address
RegularExpressionValidator Validate = new RegularExpressionValidator();

Validate.ControlToValidate = TXT_Currency_Value.ID;
Validate.ErrorMessage = " - * Enter valid email";
Validate.Display = ValidatorDisplay.Dynamic;
Validate.ValidationExpression=@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
3) Validating an Number or decimal (for currency)

RegularExpressionValidator Validate = new RegularExpressionValidator();
Validate.ControlToValidate = TXT_Currency_Value.ID;
Validate.ErrorMessage = " - * Enter valid currency";
Validate.Display = ValidatorDisplay.Dynamic;
Validate.ValidationExpression = @"^(\d{0,13}\.\d{0,5}

\d{0,13})$";

4) Validating an Mobile Number

RegularExpressionValidator Validate = new RegularExpressionValidator();

Validate.ControlToValidate = TXT_Mobile.ID;
Validate.ErrorMessage = " - * Enter valid 10 digit mobile number";
Validate.Display = ValidatorDisplay.Dynamic;
Validate.ValidationExpression = @"^([7-9]{1})([0-9]{9})$";

5) Validate Website Address
RegularExpressionValidator Validate = new RegularExpressionValidator();

Validate.ControlToValidate = TXT_WebSite_Value.ID;
Validate.ErrorMessage = " - * Enter valid email address";
Validate.Display = ValidatorDisplay.Dynamic;
Validate.ValidationExpression = @"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?";


You May Also Like

0 comments