Reputation: 18096
I am trying to avoid spaces in the Textbox and prevent the user to enter any spaces. I tried
<ajaxToolkit:FilteredTextBoxExtender ID="Filteredtextboxextender2" runat="server"
FilterType="Custom" InValidChars=" "
TargetControlID="tx_username">
</ajaxToolkit:FilteredTextBoxExtender>
but it didn't work. Is there any other solutions ?
Upvotes: 0
Views: 3762
Reputation: 3459
You need client side validation please check all the options available for you:
http://msdn.microsoft.com/en-us/library/yb52a4x0(v=vs.100).aspx
also if I were you I would just use something like this:
$("#username").keypress(function(e) {
if(e.which == 32) {
e.preventDefault();
}
})
which requires jQuery of course you can use pure Javascript if you like :)
Upvotes: 3