validation on textbox (no space)
asp.net
Solution
If you intended to capture a value where spaces aren't a valid character, you could use a RegularExpressionValidator:
<asp:RegularExpressionValidator ID="rev" runat="server" ControlToValidate="txtBox"
ErrorMessage="Spaces are not allowed!" ValidationExpression="[^\s]+" />
<asp:RequiredFieldValidator ID="rfv" runat="server" ControlToValidate="txtBox"
ErrorMessage="Value can't be empty" />
This would prevent "hello world" and "data base" since they contain spaces, and would only allow "helloworld" and "database" as valid values. You must use a RequiredFieldValidator in conjunction with it to prevent blank entries since the RegularExpressionValidator does not prevent that on its own.
Specify the name of the textbox in the `ControlToValidate` property.
Problem
i have a webpage in that i have a text box, my requirement is i don't want to give space in the textbox if user give space in textbox it give indication no space in the textbox