Click here to Skip to main content
15,034,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have text box txtstdcode which take std code of user. txtstdcode is not mandatory field. so that user can't force to enter std code. i set the max length std code is 3. if user enter white space without enter std code it has to show error 'Dont enter space'. i dont want to use javascript .

Manohar Khillare

1 solution

Hey there,

Try RegularExpressionValidator:

<asp:regularexpressionvalidator id="rev" runat="server" controltovalidate="txtBox" xmlns:asp="#unknown">
    ErrorMessage="Spaces are not allowed!" ValidationExpression="[^\s]+" /></asp:regularexpressionvalidator>

Let me know if it helps.

Manohar Khillare 7-Oct-13 2:54am
no its not working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900