Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom validator 1

Status
Not open for further replies.

boatdrinks

IS-IT--Management
Jun 18, 2004
51
US
I have a custom validator and would like to set it to allow between 1 and 500 characters. I would also like to allow certain characters like .,'!@$%*&()+=- I really only want to exclude <>. Is there any way I can do this?

<asp:RegularExpressionValidator id="problemvalidator2" ControlToValidate="insertproblem" display="dynamic" ErrorMessage="&nbsp&nbsp;Problem Description cannot exceed 500 characters" ValidationExpression=".{1,500}" runat="server" />
 
ValidationExpression="^[^<>]{1,500}$"
This does not give an error if nothing is entered as
".{1,500}" also allows nothing to be entered. You might also want to use a RegularExpressionValidator and a RequiredFieldValidator or someone may post a regex that also makes sure there is at least 1 character.
Marty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top